当我运行scraper获取下一页的href链接时,我可以看到它获取了[javascript:void(0);]而不是传统的href。反正我也不能利用它。如果有人能帮我解决问题,我会很高兴的。我使用的代码:
import requests
from lxml import html
url="http://www.findanarchitect.com.au/index.php"
def Endpoint(Address):
payload = {'action':'show_search_result','action_spam':'dDfgEr','txtSearchType':5,'txtPracName':'','optSstate':3,'optRegions':23,'txtPcode':'','txtShowBuildingType':0,'optBuildingType':1,'optHomeType':1,'optBudget':''}
response = requests.post(Address, data = payload)
tree=html.fromstring(response.text)
titles=tree.xpath('//div[@id="pagination"]')
for title in titles:
Links=title.xpath('.//li[@class]/a/@href')
for Link in Links:
print(Link)
Endpoint(url)
Html元素位于:
^{pr2}$我得到的结果是:
在html上有
js_go_to_page
函数您需要在爬虫程序代码中重新生成
furl
变量的内容,这一点很有挑战性,因为action
是静态的,page_no
是要获取的页面的编号,$('#idSubSearchType').val()
可以用html解析器读取。在相关问题 更多 >
编程相关推荐