爬网页,代码如下,但是运行结果为空,求解
import requests
from bs4 import BeautifulSoup
url1="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")
孤独的小猪
慕瓜9220888
pardon110
相关分类