0%
2022年5月4日 星期三
bs4 学习网址
bs4学习网址
- BeautifulSoup 导入bs4库以后,你要告诉bs解析成何种代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| import requests from bs4 import BeautifulSoup
url='https://b.faloo.com/1134941.html/' domain = "https://umei.net" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36" }
response=requests.get(url,headers=headers) response.encoding='gbk' html = BeautifulSoup(response.text,'html.parser')
ul=html.select("div .DivTd a") print(type(ul)) print(ul) print(html.a) print(html.a.string) print(html.a['href']) for a in ul: print(a.text) print(a.get('href').strip('//'))
|