import requests from bs4 import BeautifulSoup

url = 'https://m.okooo.com/match/change.php?mid=1194233&pid=24&Type=odds' headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3', 'Referer': 'https://m.okooo.com/', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', } res = requests.get(url, headers=headers) res.encoding = 'gbk' soup = BeautifulSoup(res.text, 'html.parser') companies = soup.select('.company a') for company in companies: print(company.text, company['href']

写一段python代码 请求时带请求头请求httpsmokooocommatchchangephpmid=1194233&pid=24&Type=odds将页面编码改为gbk解析返回值中的公司名称和链接地址将解析的结果打印

原文地址: https://www.cveoy.top/t/topic/dxEE 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录