Giter VIP home page Giter VIP logo

acciotables's Introduction

https://acciotables.herokuapp.com

API to scrape dynamically generated contents in a webapge.

This API takes in the url of a webpage and css selector id of the content to be scrapped and returns the outer html text of the scrapped content. It is hosted in heroku and works using Puppeteer (to enable headless scraping) and ExpressJS (to serve the app).

Reference Detail
API Format https://acciotables.herokuapp.com/?page_url=some_content&content_selector_id=some_content
Attributes page_url : The URL of the webpage on which the content to be scrapped is available (in html encoded format)
content_selector_id : CSS Selector ID of a particular table or any html element (in html encoded format)
Request Method GET : GET methods means the API returns you something you ask
Response Type text/html : Outer HTML content of the scrapped table (or any html element)

Sample usage:

Note: Since the API is deployed on Heroku, it might take a while to wake the web process if the webapp had been idle for last few minutes and needs to be moved from idle to running. Once it's up and running it will take a maximum of 4 seconds to produce the result.

  • From the above image we get to know that the css selector id for the "Squads Goalkeeping" table is #stats_keeper_squads.
  • In order to scrap the table, all we need to do is call the API as http://acciotables.herokuapp.com/?page_url=https://fbref.com/en/comps/22/Major-League-Soccer-Stats&content_selector_id=%23stats_keeper_squads. Note that # is replaced with its ASCII value %23 as URL's don't accept some symbols. Remember to swap # with %23 or refer to this page for more details for encoding other symbols.
  • The result is as follows: (we get the table in html format)

Calling the API in R:

require(rvest)
require(dplyr)
page <- read_html("http://acciotables.herokuapp.com/?page_url=https://fbref.com/en/comps/22/Major-League-Soccer-Stats&content_selector_id=%23stats_keeper_squads")
table <- page %>% html_table()
table <- table[[1]] 
print(table)

Using the API in Python:

import pandas as pd
url = "http://acciotables.herokuapp.com/?page_url=https://fbref.com/en/comps/22/Major-League-Soccer-Stats&content_selector_id=%23stats_keeper_squads"

df = pd.read_html(url,header=0)
print(df)

acciotables's People

Contributors

npranav10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

acciotables's Issues

Hosting is down

Hi, I am looking to scrape football data from fbref using your API: https://acciotables.herokuapp.com. However, the hosting seems to be down since the page loads an application error from Heroku. Are you able to continue hosting this API, as I would really like to use it.

Cheers,
Jeffrey

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.