SHARE
TWEET

Python - web scraping - World Cup 2018

furas Jun 16th, 2018 (edited) 223 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4. page=requests.get('https://www.fifa.com/worldcup/matches/?cid=go_box')
  5. soup = BeautifulSoup(page.text,'html.parser')
  6.  
  7. #items = []
  8.  
  9. rows = soup.find_all('a', class_='fi-mu__link')
  10. for row in rows:
  11.     date = row.find('div', class_='fi-mu__info__datetime')
  12.     date = date.text[7:20]
  13.     teams = row.find_all('span', class_='fi-t__nText')
  14.     team1 = teams[0].text
  15.     team2 = teams[1].text
  16.  
  17.     #items.append( [date, team1, team2] )
  18.  
  19.     print('Date:', date)
  20.     print(f'Teams: {team1} VS {team2}')
  21.     print('---------------------------------')
  22.  
  23. #for date, team1, team2 in items:
  24. #    print('Date:', date)
  25. #    print(f'Teams: {team1} VS {team2}')
  26. #    print('---------------------------------')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top