我試圖用硒和Python來打印一些信息,但它打印不是所有的CSS的路徑,這是while循環怎麼會只是一個信息打印信息..如何使用硒
pageIndex = 1
while True: # Keep looping through all pages
# Navigate to the search page
browser.get("https://www.houz.com/page_num="+ str(pageIndex))
time.sleep(6)
links = browser.find_elements_by_css_selector('div > h3 > a')
for link in links:
urls = link.text
jobs = browser.find_elements_by_css_selector('div > div.description')
for title in jobs:
jobtitles = title.text
with open("1Exportdata.csv", "a") as csvFile:
csvFile.write(url + "," + jobtitle + "\n")
pageIndex += 1
if pageIndex == 5010:
browser.close()
剛剛運行'for'循環爲'urls'和'jobtitles'分配新值有什麼意義? – Andersson
剛剛更新的全閉環 – Sarfraz