我正在开发一个基于selenium的爬虫程序。我希望能够https://sukebei.nyaa.si/?s=seeders&“o=desc”(这是一个色情网站),并且只在那天下载所有的torrent。因此,我必须使用“driver.find_element_by_link_text(“日期”)”来检测日期是否正确,并将这些元素保存为列表。之后,我不知道该怎么做才能点击日期旁边的超链接。 如果你有任何想法,请让我知道,谢谢。(由一位英语不好的台湾高中生提供。) part of html of that webimage of that web
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
import time
date="2021-"
month=input("what month is it?")
day=input("which day is it?")
print(date+month+"-"+day)
url="https://sukebei.nyaa.si/?s=seeders&o=desc"
driver_path = "C:\\webdriver\\chromedriver.exe"
option = webdriver.ChromeOptions()
driver = webdriver.Chrome(driver_path, options=option)
driver.implicitly_wait(10)
driver.get(url)
j=1
for j in driver.find_element_by_link_text("date"):
time.sleep(20)
您需要形成正确的日期(使用web中显示的表单),然后通过链接文本或显示日期的属性查找元素,但查找元素,而不是元素:
然后,你有你想要的元素;您只需要选择所需的部分,您需要一个for或什么来定位选择的任何元素,您需要执行以下操作:
您可以将要保存的属性放入(“”)
相关问题 更多 >
编程相关推荐