Python爬取澳超比赛FID代码示例
import requests
url = 'https://liansai.500.com/zuqiu-500/timetable-10067.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)
if response.status_code == 200: fid_list = [] data = response.text start_index = data.index('var matchlist') end_index = data.index('var totalpage') matchlist_str = data[start_index:end_index] matchlist_lines = matchlist_str.split(' ') for line in matchlist_lines: if 'fid' in line: fid_str = line.split(':')[1].strip().replace(',', '') fid_list.append(fid_str) print(fid_list) else: print('请求失败')
原文地址: https://www.cveoy.top/t/topic/nIUt 著作权归作者所有。请勿转载和采集!