Home > Mobile >  Data Scraping Futbin player images
Data Scraping Futbin player images

Time:10-09

    for page in range(1, 5):
        req = requests.get('https://www.futbin.com/players?page=' str(page))
    soup = bs4.BeautifulSoup(req.text,'html.parser')

   numbers = [1,2]
   for number in numbers:
       players = soup.findAll('tr','player_tr_' str(number))
       for p in players:

       x = p.select('img[src^="https://cdn.futbin.com/content/fifa22/img/"]')
       clubImage = x[0]['src']
       nationalityImage = x[1]['src']
       leagueImage = x[2]['src']

Hi,I'm scraping from Futbin.com with this method, I can access the club picture, country picture and league picture of the players. But I can't access the player's own picture. I just want to access the link where the player is. How can I do it? Check image

image

CodePudding user response:

Try this:

for page in range(1, 5):
    req = requests.get('https://www.futbin.com/players?page=' str(page))
    soup = bs4.BeautifulSoup(req.text,'html.parser')

    players = soup.findAll('img')
    for p in players:

        x = p.get("data-original")
        if x and "players" in x:
            print(f"Name: {p.get('alt')}; Link: {x}")

Output

Name: Pelé 98; Link: https://cdn.futbin.com/content/fifa22/img/players/237067.png?v=23
Name: Diego Maradona 97; Link: https://cdn.futbin.com/content/fifa22/img/players/190042.png?v=23
Name: Ronaldo 96; Link: https://cdn.futbin.com/content/fifa22/img/players/37576.png?v=23
Name: Zinedine Zidane 96; Link: https://cdn.futbin.com/content/fifa22/img/players/1397.png?v=23
Name: Diego Maradona 95; Link: https://cdn.futbin.com/content/fifa22/img/players/237074.png?v=23
Name: Pelé 95; Link: https://cdn.futbin.com/content/fifa22/img/players/237068.png?v=23
Name: Ferenc Puskás 94; Link: https://cdn.futbin.com/content/fifa22/img/players/254642.png?v=23
Name: Johan Cruyff 94; Link: https://cdn.futbin.com/content/fifa22/img/players/190045.png?v=23
Name: Lev Yashin 94; Link: https://cdn.futbin.com/content/fifa22/img/players/238380.png?v=23
...................
  • Related