0

我已經使用Selenium和Python登錄了網絡。現在我想查找所有的href鏈接並下載/保存鏈接的網頁,而不使用.click()。 的href是像硒Python如何從href中獲取網頁內容而不點擊它

<a href="project.cfm?CFID=162805&amp;CFTOKEN=98566707&amp;fromlist=1&amp;project_refid=10700290" target="_parent">sth (2) - 2 xox | oo - xx dd </a> 

link example

+0

[使用Python請求獲取html?]的可能的副本(https://stackoverflow.com/questions/27803503/get-html-using-python-requests) – JeffC

回答

-1

首先,你可以使用下面

listOFLinks =driver.find_elements_by_xpath("//a") 

然後遍歷列表得到的鏈接

for link in listOFLinks 
url = link.getAttribute("href"); 

可以打印網址根據您的需求將其變量或保存到一個數組中ent

+1

這不會按照請求保存網頁。 – JeffC