我想做的是制作一个让我运行的简单程序,它基本上会转到 Torrentz 并按照一些链接最终能够通过 uttorent 下载文件。以下是我到目前为止编写的代码,我似乎无法使变量linkElem
工作。而且我似乎也无法linkElem.find_elements_by_xpath
访问必要的链接。如果您认为自己知道出了什么问题,请提供帮助。谢谢。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = webdriver.Firefox()
browser.get('https://torrentz.eu/')
searchElem = browser.find_element_by_id('thesearchbox')
searchElem.send_keys('Limitless')
searchButton = browser.find_element_by_id('thesearchbutton')
searchButton.click()
linkElem = linkElem.find_elements_by_xpath("//div[@class='results']//a[@href='/9ea0c575520a3065d85b285c9474231192368db7']")
#wait = WebDriverWait(browser, 6)
#linkElem = wait.until(EC.visibility_of_element_located((By.href, "/9ea0c575520a3065d85b285c9474231192368db7")))
#linkElem.clear()
#linkElem = browser.find_element_by_link_text('S01E20 HDTV x264 LOL ettv')
#linkElem.click()
#SignIn = browser.find_elements_by_id('signIn')
#SignIn.click()
#passwordElem.submit()