我想自动单击喜欢的蓝色徽标(内部拇指的徽标),以打开那些留下喜欢的人的列表。我指的是这个小蓝色徽标:
在我只想关注这个小请求的问题中,这是一个小单击。我想我做对了,但是肯定有问题。我使用 by.xpath
。,更精确: //*[@ID =“ JSC_C_Z”]/span [1]/span/span/span/span/div
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="jsc_c_z"]/span[1]/span/span/div'))).click()
nota:i' VE注意到,此页面上的ID和范围看起来令人怀疑,因此也许每次它们都不一定是一样的。因此,也许我不认为ID =“ JSC_C_Z”将是可靠的。您可能需要诉诸于目标元素div上的属性的aria-labeld。
相反,这是我想打开的链接。
重要的是:您必须输入Facebook登录,但是谁不想这样做会发布屏幕截图
我希望有人可以帮助我。谢谢
I would like to automatically click on the blue logo of the likes (the one with the thumb inside), in order to open the list of those who have left the likes. I am referring to this little blue logo:
In the question I want to focus only on this small request, on this small click. I think I am doing it right, but surely there is something wrong. I used By.XPATH
., More precisely: //*[@id="jsc_c_z"]/span[1]/span/span/div
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="jsc_c_z"]/span[1]/span/span/div'))).click()
NOTA :I've noticed that the IDs and ranges on this page look suspiciously obfuscated and so maybe they won't necessarily be the same every time. So maybe I don't think id = "jsc_c_z" that will be reliable. You may need to resort to using aria-labeld of the attribute on the target element div.
This instead is the link I would like to open https://www.facebook.com/FranzKafkaAuthor/posts/3985338151528881.
IMPORTANT: You have to enter with the Facebook login, but who does not want to do so will post a screenshot
I hope someone can help me. Thanks
发布评论
评论(3)
嘿,您可以尝试这样的XPATH,
因为图像标签具有链接,而不是DIV标签
如果它不起作用,请尝试在定位DIV时添加Arial标签。
Hey you can try the Xpath like this,
as the image tag has the link and not the div tag
If it does not work, try adding the arial label while locating the div.
此页中的ID和跨度看起来令人怀疑,因此每次都不一定是相同的。我认为
id =“ JSC_C_Z”
是可靠的。您可能需要诉诸于目标div
元素上的aria-label
属性。我无法测试这一点,但是xpath将是类似的东西。当然,如果您要为具有不同语言的用户运行此文本,则需要更改该文本。
the ids and spans in this page look suspiciously obfuscated, and thus won't necessarily be the same every time. I don't think the
id="jsc_c_z"
will be reliable. you may need to resort to using thearia-label
attribute on the targetdiv
element. I can't test this, but the xpath would be something along the lines of;and of course, you'd need to change that text if you are running this for users with different languages.
我自己解决了。解决方案是:
I solved it by myself. The solution was: