import requests from bs4 import BeautifulSoup base_url = 'your_base_url_here' # 根据网站的实际URL模式修改此函数 def get_page_url(page_number): return f'{base_url}?page={page_number}' # 根据网站的HTML结构,您可能需要修改以下选择器以获取游戏标题 def get_game_titles(soup): return soup.select('span.title') for page_number in range(1, 198): url = get_page_url(page_number) response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') game_titles = get_game_titles(soup) print(f'Page {page_number}:') for title in game_titles: print(title.text) print('\n')
标签:get,python,程序,number,爬虫,url,titles,page,soup From: https://www.cnblogs.com/chelseatan/p/17279889.html