Python Forum
How can I target and scrape a data-stat
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I target and scrape a data-stat
#3
thanks for the reply.

I can't get this working here is my code.

I have it trying to print clubs first to see if I can connect.. it was working and returning the whole table.. but it's not now, not sure why.
Even when it was returning the whole table in print, the print on "name" wasn't working.

from bs4 import BeautifulSoup
import requests

try:
    html = requests.get('https://fbref.com/en/squads/19538871/Manchester-United-Stats')
    html.raise_for_status()

    soup = BeautifulSoup(html.text, 'lxml')

    clubs = soup.find(class_='stats_table')

    for club in clubs:
        name = club.find('div', {'data-stat': 'player'})

        print(clubs)

except Exception as e:
    print(e)
I'm getting this message on print
slice indices must be integers or None or have an __index__ method
Reply


Messages In This Thread
RE: How can I target and scrape a data-stat - by never5000 - Feb-10-2022, 06:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 1,058 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  I am trying to scrape data to broadcast it on Telegram BarryBoos 1 2,411 Jun-10-2023, 02:36 PM
Last Post: snippsat
  Is it possible to scrape this data from Google Searches rosjo 1 2,258 Nov-06-2020, 06:51 PM
Last Post: Larz60+
  [WinError 10061] No connection could be made because the target machine actively refu kannanponraj 1 8,580 May-10-2020, 10:39 AM
Last Post: Larz60+
  scrape data 1 go to next page scrape data 2 and so on alkaline3 6 5,444 Mar-13-2020, 07:59 PM
Last Post: alkaline3
  Want to scrape a table data and export it into CSV format tahir1990 9 5,487 Oct-22-2019, 08:03 AM
Last Post: buran
  webscrapping links and then enter those links to scrape data kirito85 2 3,348 Jun-13-2019, 02:23 AM
Last Post: kirito85
  Scrape ASPX data with python... hoff1022 0 4,601 Feb-26-2019, 06:16 PM
Last Post: hoff1022
  Target: Web Scraping / Web Automation vetabz 2 3,729 May-07-2017, 01:47 PM
Last Post: vetabz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020