a public service for webscraping
OpenScraper is a minimalistic, open source webscraper with a simple interface, so almost anyone with very little technical knowledge could scrap public data and install/adapt it for its own purposes... for free.
... anyway, that's the goal folks ! ...
(it's a development phase for now)
#python #tornado #scrapy #selenium #mongodb #bulma
WHAT IS NEW ?
- v1.3 - 20/10/2018 : added first csv converter and downloader for every spider's dataset and first routes to documentation
- v1.2 - 18/10/2018 : a spider can adapt to follow pages either if they are API or HTML
- v1.1 - 15/10/2018 : parser adapts to API Rest, configuration based on "/" description for the path inside the JSON
- v1.0 - 10/06/2018 : parser adapts to reactive website (SPA, vue, etc...)
- vBeta : Scrapy parser based on spider configuration with Xpaths
To which needs this project aims to answer ?
Scraping can quickly become a mess, mostly if you need to scrap several websites in order to eventually get a structured dataset. Usually you need to set up several scrapers for every website, configure the spiders one by one, get the data from every website, and clean up the mess to get from this raw material one structured dataset you know that exists...
Yes, similar solutions already does exist... but...
So you have mainly three options when it comes to scrap the web :
- either use a proprietary and quite expensive service (like Apify or import.io) and depend on an external service ;
- ask a friend if you are lucky, ask a developer or a company to do it for you if you have money for that...
- or if you have the know-how write your own code (for instance based on BeautifulSoup or Scrapy), adapt it for your own purposes, and usually be the only one (I mean the only developer around) to be able to use/adapt it.
A theoretical use case
So let's say you are a researcher, a journalist, a public servant in an administration, a member of any association who want to survey some evolutions in the society... Let's say you need data not easy to get, and you can't afford to spend thousand of euros in using a private service for webscraping.
You'd have a list of different websites you want to scrap similar information from, each website having some urls where are listed those data (in our first case social innovation projects). For every information you know it could be similarly described with : a title, an abstract, an image, a list of tags, an url, and the name and url of the source website, and so on...
So to use OpenScraper you would have to :
- specify the data structure you expect ("title", "abstract", etc...) ;
- add a new contributor (a source website) : at least its name and the start_url from which you'll do the scraping ;
- configure the spider for every contributor, i.e. specify the xpaths for every field (xpath for "title", xpath for "abstract", etc... );
- save the contributor spider configuration, and click on the "run spider" button...
- the data will be stored in the OpenScraper database (MongoDB), so you could later retrieve the structured data (with an API endpoint or in a tabular format like a .csv file)
An open scraper for more digital commons
To make that job a bit easier (and far cheaper) OpenScraper aims to display an online GUI interface (a webapp on the client side) so you'll just have to set the field names (the data structure you expect), then enter a list of websites to scrap, for each one set up the xpath to scrap for each field, and finally click on a button to run the scraper configured for each website...
... and tadaaaa, you'll have your data : you will be able able to import it, share it, and visualize it (at least we're working on it as quickly as we can)...
OpenScraper is developped in open source, and will provide a documentation as much as a legal framework (licence and CGU) aiming to make the core system of OpenScraper fit the RGPD, in the letter and in the spirit.
clone or download the repo
install MongoDB locally or get the URI of the MongoDB you're using
- on MacOS :
$ brew tap caskroom/cask $ brew cask install chromedriver
- on Ubuntu :
$ sudo apt-get install chromium-chromedriver
go to your openscraper folder
install the libraries (without virtual environment)
$ pip install -r requirements.txt
config/settings.pyfile with your mongoDB URI (if you're not using default mongoDB connection)
run app from
$ python main.py
check in your browser at
create/update your datamodel at
create/update your spiders at
run the test spider in the browser by clicking on the test spider at
- get a server - check digital ocean, OVH, ...
- optionnal : get a domain name : check OVH, namecheap, godaddy....
- follow (most of) these instructions
- pray for all that to work...
- Language : Python... because let's be honest, I don't manage so many languages for that kind of project
- Backend : Tornado... one of the few async/non-blocking Python frameworks
- Scraping : Scrapy, with Selenium for Python inside specific instances of the generic spider, or Splash for jquery follow-up...
- Frontend : Bulma (to make it nice) and then Vue.js (to make it even nicer and bi-directional)
Tech goals for a MVP
- web interface to edit the data structure
- Python asynchronous interface (Tornado) for Scrapy
- store a list of url sources + corresponding xpaths in a DB (Mongo)
- web interface to edit the sources' xpath list
- display the list of sources + for each add a button to run the scraper
- store/extract results in the DB
ROADMAP TO A MVP
To do list :
- DONE - understand basics of Tornado (reuse some tutorial material)
- DONE - basic Tornado + MongoDB setup
- DONE - understand basics of Scrapy
- DONE - UI to create user (register), create/update a datamodel, create/update a spider configuration
- DONE - add a GUI to configure the data structure you expect from the scraping
- DONE - create a generic spider (class) + generic item to fill, both callable from handlers
- DONE - integrate generic spider + tests + run
- DONE - make Tornado and a basic scrapy spider work together (non-blocking)
- DONE - make a nice front in Bulma
- DONE - add Selenium to mimic navigation by clics on reactive websites
- DONE - add API points for JSON feeds
- DONE - add an "export csv" button and function to download the dataset
- deploy a demo at http://www.cis-openscraper.com/
- ... nicer front in vue.js
- integrate JWT and hash private infos for users and API
- adding documentation ...
Notes for later / issues :
- must migrate/copy data to a Elastic search (not only MongoDB)
- containerize the app for simpler deployment (locally or in production)
OpenScraper's team thanks :
- the SocialConnect project, aka "Carrefour des Innovations Sociales"
- the EIG program by Etalab
- the CGET