import requests
from bs4 import BeautifulSoup

url = 'https://odds.500.com/fenxi/ouzhi-1059047.shtml'

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.36 Edge/16.16299'
}

response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')

company_list = soup.select('.tb-plist .tb-plist-team a')
for company in company_list:
    print(company.text, company['href'])

代码功能:

  1. 访问500彩票网站赔率页面 https://odds.500.com/fenxi/ouzhi-1059047.shtml
  2. 自动构造请求头,模拟浏览器访问
  3. 使用BeautifulSoup解析网页内容
  4. 提取所有公司的名称和对应链接
  5. 打印输出结果
Python代码解析500彩票网站赔率数据

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

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