Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrap Football data table of previous matches from the official football data websites (fbref...) #1076

Closed
wants to merge 1 commit into from

Conversation

Prathamg001
Copy link

Description

The process of scraping a football squad stats table from a webpage and saving it to an Excel file involves several key steps. First, necessary Python libraries are imported: requests for handling HTTP requests, pandas for data manipulation and storage, and BeautifulSoup from the bs4 library for parsing HTML content. The URL of the webpage containing the football squad statistics is specified, and an HTTP GET request is sent to retrieve the webpage content. The success of the request is verified by checking if the status code is 200.

Once the webpage content is successfully retrieved, BeautifulSoup is used to parse the HTML content. The specific stats table is located using CSS selectors, targeting the third table with the class stats_table. The data is then extracted by looping through the rows of the table, collecting the text from each cell in the row, and storing it in a list. The first row is assumed to contain the column headers, defining the structure of the data.

A Pandas DataFrame is created using the extracted data, with the first row as the headers. Finally, this DataFrame is saved to an Excel file named "Team Score.xlsx". This process allows for efficient extraction, manipulation, and storage of football squad statistics in a structured format suitable for further analysis. If the stats table is not found or the webpage retrieval fails, appropriate messages are printed to indicate the issues.

The changes made in this pull request should be briefly described.

Resolves: [1067]

Checklist

Before submitting this pull request, kindly verify that the ensuing checkpoints have been reached.

  • [✅] Have you adhered to the repository's defined coding convention rules?
  • Have you updated the 'documentation.md' file with the method/function documentation?
  • [✅ ] Have you sent a message along with the result or response?
  • Have you used the try-catch technique?
  • Has the method/class been added to the documentation (md file)?

Screenshots

image

image

Uploading a screenshot illustrating the approach you developed for validation is required.

Additional Notes/Comments

  1. Each team data can be scraped by the code given
  2. It will help to analyze and perform future prediction of football results.
  3. For each team the code should be modified with the link for stats of each team

Any additional remarks or suggestions concerning this pull request are welcome.


I certify that I have carried out the relevant checks and provided the requisite screenshot for validation by submitting this pull request.
I appreciate your contribution.

@nikhil25803 nikhil25803 closed this Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants