|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
照葫芦画瓢
- import requests #加载模块
- import bs4
- head={}
- head['User-Agent']= "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3775.400 QQBrowser/10.6.4209.400"
- #head伪装浏览器
- res = requests.get("https://cpu.51240.com/",headers=head)
- soup = bs4.BeautifulSoup(res.text,"html.parser")
- targets = soup.find_all("div",class_="mingcheng") #数据路径
- for each in targets:
- print(each.b.text,each.a.text) #打印排名和名称
复制代码
|
|