Giter VIP home page Giter VIP logo

declaration.ge-pdf-scraper's Introduction

Declaration.ge Scraper Suite

BeautifulSoup is required.

NOTE: declaration.ge recently added a bunch of archival documents in the form of scanned PDFs. This created a gap in the database IDs for the non-scanned PDFs that are downloaded by the download script. To get both sets, you will need to run the download script twice. The first time, call the script with arguments ' 0 1000' and the second time ' 43000 1000'.

NOTE: declaration.ge was recently updated to include English declarations. The download script will download Georgian and English declarations into separate folders ("en" and "ka"), but the parse script does not work for English at the moment, only Georgian. You will need to point the scripts at reports/ka in order to target the Georgian files only.

In order to scrape a PDF file downloaded from declaration.ge, you will first need to convert it to HTML. You will need to use poppler, which contains pdftohtml which is used by scripts/tohtml. However, not all versions of pdftohtml are guaranteed to work. The source for poppler 0.16.7 is included for your convenience; just follow the compile instructions and you will be able to find the compiled pdftohtml binary under poppler-0.16.7/utils. You'll need to change the PDFTOHTML path in the tohtml script accordingly.

If you just want to scrape everything and output to CSV, simply build poppler and then run

scripts/full.sh

Download the reports:

$ ./scripts/download reports/

Convert them to HTML:

$ ./scripts/tohtml reports/ka/ reports/ka/

Then run:

$ python ./parse.py reports/ka/report-ID.html

to parse the HTML into a Python object. What you do with that object is up to you. Or to import all reports into a couchdb:

$ python ./db.py reports/ka

db.py will take a directory of HTML (+ PDF) files, parse them (+ build a hash of the PDF files), and load them into a CouchDB database.

Or to dump directly to CSV (pipe-delimited): $ python ./file_output.py reports/ka

CSV

You can directly export to CSV using file_output.py (see above), and a few tools are provided to export the contents of a CouchDB database to CSV.

Edit variables HOST and DB in couchctl to connect to your couchdb. Then install the design document for CSV export into the database (once!):

$ ./scripts/couchctl upview csv/forexport.json

Edit dictionary DB in csv/csv.py to connect to your couchdb. Then you can repeatedly run a python script to collect the CSV data and dump it into a directory:

$ ./csv/csv.py csvdata/

Reports

Once you have gathered some data, you can run the reporting tool to see differences between the latest two scrape runs. It will output HTML:

$ python ./report.py > result.html

Enjoy.

declaration.ge-pdf-scraper's People

Contributors

ddohler 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.