爬网页,代码如下,但是运行结果为空,求解import requestsfrom bs4 import BeautifulSoupurl1="http://seputu.com/"user_Agent="Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0"headers1={"User-Agent":user_Agent}r=requests.get(url1,headers=headers1)#print r.text#soup=BeautifulSoup(r.text,"html.parser")soup=BeautifulSoup(r.text,"lxml",from_encoding="utf-8")for target in soup.find_all(class_="box"): a=target.find("a") print a.get("href")
添加回答
举报
0/150
提交
取消