【发布时间】:2016-10-14 02:50:46
【问题描述】:
我正在尝试获取团队每个页面的所有游戏结果。到目前为止,我能够获得所有对手 1 对对手 2 的结果并得分。但我不知道如何获取下一页以获取其余数据。我会找到下一页并将其放入while循环吗?这是我想要的团队的链接
http://www.gosugamers.net/counterstrike/teams/7397-natus-vincere/matches
这是我目前所拥有的,它只记录了所有球队的比赛和得分。
def all_match_outcomes():
for match_outcomes in match_history_url():
rest_server(True)
page = requests.get(match_outcomes).content
soup = BeautifulSoup(page, 'html.parser')
team_name_element = soup.select_one('div.teamNameHolder')
team_name = team_name_element.find('h1').text.replace('- Team Overview', '')
for match_outcome in soup.select('table.simple.gamelist.profilelist tr'):
opp1 = match_outcome.find('span', {'class': 'opp1'}).text
opp2 = match_outcome.find('span', {'class': 'opp2'}).text
opp1_score = match_outcome.find('span', {'class': 'hscore'}).text
opp2_score = match_outcome.find('span', {'class': 'ascore'}).text
if match_outcome(True): # If teams have past matches
print(team_name, '%s %s:%s %s' % (opp1, opp1_score, opp2_score, opp2))
【问题讨论】:
标签: python python-3.x web-scraping beautifulsoup html-parsing