【发布时间】:2020-08-11 19:21:13
【问题描述】:
我最近一直在研究我的 instagram 机器人,但我唯一的问题是找到 xpath。 在成功完成喜欢和 cmets 之后,我也开始关注。 我想跟踪我的机器人在 csv 文件中关注的人。我成功地做到了!我能够使用代码制作文件。尝试获取用户名如何成为一个问题,因为我似乎无法获取用户名的 xpath 来获取文本。我在网上搜索了 xpath 并找不到任何关于它的信息。 我应该按类搜索元素吗?
usr = driver.find_element_by_xpath('Can't find this xpath').text
try:
if usr not in prev_user_list:
if driver.find_element_by_xpath("Can't find this xpath").text == "follow":
print("following " + usr)
driver.find_element_by_xpath("Can't find this xpath").click()
time.sleep(10)
print("Followed! adding to the list...")
new_followed.append(usr)
print(usr + " has been added to the list")
【问题讨论】:
-
你能分享一个关于你找不到的元素的 HTML 代码 sn-p 吗?
标签: python selenium selenium-webdriver xpath selenium-firefoxdriver