GithubHelp home page GithubHelp logo

pixeleate / scraping-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weld-io/scraping-service

0.0 1.0 0.0 49 KB

REST API for scraping dynamic websites using Node.js, headless Chrome and Cheerio.

License: MIT License

JavaScript 100.00%

scraping-service's Introduction

Scraping Service

Scraping Service is a REST API for scraping dynamic websites using Node.js, headless Chrome and Cheerio.


Made by the team at Weld (www.weld.io), the #codefree web/app creation tool:

Weld

How to Run

Start Chrome in headless mode first:

# Mac OS X
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --remote-debugging-port=9222

Then start Scraping Service with:

npm run-script dev # development

or

npm start # production

Server will default to http://localhost:3036

How to Test

npm test

How to Use

Do a HTTP GET:

http://localhost:3036/api/scrape?url=https://news.ycombinator.com&selector=.title+a

Results:

{"time":792,"results":[{"selector":".title a","count":61,"items":["Ask a Female Engineer: Thoughts on the Google Memo", ...]}]}

Parameters:

  • url (required)
  • selector is a JQuery style selector, defaults to body. You can use multiple selectors separated by comma, which leads to more items in the results array.
  • time e.g. &time=5000 adds extra loading time before accessing DOM.
  • deep set to true to get recursive object trees, not just first-level text contents.
  • complete set to true to get full DOM nodes, not just text contents.

Implementation

Built on Node.js, Express, headless Chrome, Cheerio.

Deploying on Heroku

Stack: Heroku-16

Buildpacks:

1. https://github.com/heroku/heroku-buildpack-google-chrome
2. heroku/nodejs

Procfile:

web: /app/.apt/usr/bin/google-chrome & node app/server.js

Heroku set-up

# Set up and configure app
heroku create MYAPPNAME
heroku config:set NODE_ENV=production

# Stack and Buildpacks
heroku stack:set heroku-16
heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-google-chrome

scraping-service's People

Contributors

tomsoderlund avatar

Watchers

James Cloos 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.