Skip to main content

About Lazyscraper

Lazyscraper is a simple command line tool and library, a swiss knife for scraper writers. It’s created to work only from command line and to make easier scraper writing for very simple tasks like extraction of external urls or simple table.

Supported patterns

  • simpleul - Extracts list of urls with pattern ul/li/a. Returns array of urls with “_text” and “href” fields

  • simpleopt - Extracts list of options values with pattern select/option. Returns array: “_text”, “value”

  • exturls - Extracts list of urls that leads to external websites. Returns array of urls with “_text” and “href” fields

  • getforms - Extracts all forms from website. Returns complex JSON data with each form on the page

Command-line tool

Usage: lazyscraper.py [OPTIONS] COMMAND [ARGS]…

Options:
--help

Show this message and exit.

Commands: * extract Extract data with xpath * gettable Extracts table with data from html * use Uses predefined pattern to extract page data

Examples

Extracts list of photos and names of Russian government ministers and outputs it to “gov_persons.csv”

python lscraper.py extract –url http://government.ru/en/gov/persons/ –xpath “//img[@class=’photo’]” –fieldnames src,srcset,alt –absolutize True –output gov_persons.csv –format csv

Extracts list of ministries from Russian government website using pattern “simpleul” and from UL tag with class “departments col col__wide” and outputs absolutized urls.

python lscraper.py use –pattern simpleul –nodeclass “departments col col__wide” –url http://government.ru/en/ministries –absolutize True

Extracts list of territorial organizations urls from Russian tax service website using pattern “simpleopt”.

python lscraper.py use –pattern simpleopt –url http://nalog.ru

Extracts all forms from Russian tax service website using pattern “getforms”. Returns JSON with each form and each button, input and select

python lscraper.py use –pattern getforms –url http://nalog.ru

Extracts list of websites urls of Russian Federal Treasury and uses awk to extract domains.

python lscraper.py extract –url http://roskazna.ru –xpath “//ul[@class=’site-list’]/li/a” –fieldnames href | awk -F/ ‘{print $3}’

How to use library

Extracts all urls with fields: src, alt, href and _text from gov.uk website
>>> from lazyscraper import extract_data_xpath
>>> extract_data_xpath('http://gov.uk', xpath='//a', fieldnames='src,alt,href,_text', absolutize=True)
Run pattern ‘simpleopt’ against Russian federal treasury website
>>> from lazyscraper import use_pattern
>>> use_pattern('http://roskazna.ru', 'simpleopt')

Requirements

Metadata

Release files for lazyscraper 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lazyscraper 0.1.2
File Size Uploaded
lazyscraper-0.1.2.tar.gz 8.0 kB Details

Release files / lazyscraper-0.1.2.tar.gz

Download URL lazyscraper-0.1.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7aa22949dffeddbfc8fa0d54fe4b23060c2bae9e20c57a7d8dae5e860c2029ec
BLAKE2b-256 checksum
How to use checksums
5f9002a840d71ff46108c9161a53e9c2175b97b8dd07fbe264bef4d0fc0cfc44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page