【发布时间】:2021-08-27 04:08:54
【问题描述】:
我正在尝试使用 BitTorrent Web UI 自动下载带有磁力链接的电影。我可以单击“添加 torrent 链接”按钮,弹出窗口确实出现,但之后,代码失败,因为它无法找到需要添加 torrent 链接的元素。当我尝试输入文件位置时,也会出现同样的问题。我尝试了time.sleep,但没有运气。
我的代码 sn-p:
def torrent(path, n):
#link to web UI
driver.get("http://127.0.0.1:8080/")
#default login credentials
username = driver.find_element_by_xpath("//*[@id='username']")
username.send_keys("admin")
password = driver.find_element_by_xpath("//*[@id='password']")
password.send_keys("adminadmin")
time.sleep(2)
driver.find_element_by_xpath("//*[@id='login']").click()
time.sleep(2)
#the elements I am trying to find
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/a[1]").click()
time.sleep(5)
location = driver.find_element_by_xpath("/html/body/form/div/fieldset/table/tbody/tr[2]/td[2]")
location.send_keys(path)
input = driver.find_element_by_xpath("/html/body/form/div/textarea")
i = 0
while i <= n-1:
input.send_keys(list_torrent[i])
如果您需要任何其他信息,请告诉我。我已经尝试使用 BitTorrent API,但没有运气。 HTML 页面有一个隐藏的溢出,但这应该不是问题,因为我单击了应该使我的代码可见的元素。 提前致谢。
【问题讨论】:
标签: python html python-3.x selenium