Coder Social home page Coder Social logo

scraper-api's Introduction

Scraping a JS-Rendered webpage

Background Information

When a browser wants to access a webpage, it sends a request to the server on which the files that make up the webpage are located. The server then sends a response consisting of the page’s source code back to the browser. The browser then interprets the HTML, CSS, etc, in the source code, allows any Javascript to run, and displays the page.

Of the parts that comprise the source code of a webpage, the Javascript code is of particular interest to us in this article. When a page is loaded into a browser, it becomes a document object, whose HTML elements, or element nodes, Javascript can access. As it runs, Javascript can create new HTML elements and append them to the document. A page on which this occurs is called a page rendered by Javascript. The new elements will not be present in the original source code of the page, the code that you see when you right-click and press “view page source”; but they will be present in the code that you see if you download the page as an HTML document and open it in a text editor, or in the code in the “elements” tab in your browser’s developer tools. This HTML code, which can be retrieved by JavaScript using the DOM's innerHTMLproperty, constitutes the code of the completed webpage that the browser displays after the Javascript has finished running, and has all of the data that you need for scraping.

When scraping using python or any other language, a library like urllib or requests sends a request to the server, it receives the source code of the webpage, just like a browser does. However, Python can not run the Javascript and allow it to create the elements that hold the content that you need to scrape. And that's where this app comes in, to scrape a JS rendered website;

POST /scrape/

Request Body

{
    "url": "https://google.com"
}

scraper-api's People

Contributors

mullweisser avatar phillipahereza avatar

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.