SHARE
TWEET

Python - download FIFA images

furas Jul 6th, 2018 (edited) 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. from bs4 import BeautifulSoup as BS
  3.  
  4. url = 'https://www.fifa.com/worldcup/teams/team/43938/'
  5.  
  6. r = requests.get(url)
  7. soup = BS(r.text)
  8.  
  9. number = 1
  10.  
  11. for svg in soup.find_all('svg'):
  12.     image = svg.find('image')
  13.     if image:
  14.         href = image['xlink:href']
  15.         filename = '{}.jpg'.format(number)
  16.         print('downloading:', number)
  17.  
  18.         r = requests.get(href)
  19.         with open(filename, 'wb') as f:
  20.             f.write(r.content)
  21.  
  22.         number += 1
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