Skip to main content

No project description provided

Project description

pycrawl

build PyPi MIT License

A simple crawling utility for Python

Description

This project enables site crawling and data extraction with xpath and css selectors. You can also send forms such as text data, files, and checkboxes.

Requirement

  • Python3

Usage

Description of Instance Methods

name Description
send Set the value you want to submit to the form.
submit Submit form.
css Get node by css selector.
xpath Get node by xpath.
attr Get node's attribute.
inner_text Get node's inner text.
outer_text Get node's outer text.

Simple Example

import pycrawl

url = 'http://www.example.com/'
doc = pycrawl.PyCrawl(
	url,
	user_agent='<user agent>',
	timeout=<timeout sec>,
	encoding=<encoding>,
)

# access another url
doc.get('another url')

# get current url
doc.url

# get current site's html
doc.html

# get <table> tags as dict
doc.tables

Scraping Example

# search for nodes by css selector
# tag   : css('name')
# class : css('.name')
# id    : css('#name')
doc.css('div')
doc.css('.main-text')
doc.css('#tadjs')

# search for nodes by xpath
doc.xpath('//*[@id="top"]/div[1]')

# other example
doc.css('div').css('a')[2].attr('href') # => string object
doc.css('p').inner_text() # => string object
# You do not need to specify "[]" to access the first index

Submitting Form Example

  1. Specify target node's attribute
  2. Specify value(int or str) / check(bool) / file_name(str)
  3. call submit() with form attribute specified
# login
doc.send(id='id attribute', value='value to send')
doc.send(id='id attribute', value='value to send')
doc.submit(id='id attribute') # submit

# post file
doc.send(id='id attribute', file_name='target file name')

# checkbox
doc.send(id='id attribute', check=True)  # check
doc.send(id='id attribute', check=False) # uncheck

# example of specify other attribute
doc.send(name='name attribute', value='hello')
doc.send(class_='class attribute', value=100)
# when specifying the class attribute, please write "class_ =".

Installation

$ pip install pycrawl

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/AjxLab/PyCrawl.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycrawl-2.6.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycrawl-2.6.0-py3.8.egg (8.1 kB view details)

Uploaded Egg

pycrawl-2.6.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pycrawl-2.6.0.tar.gz.

File metadata

  • Download URL: pycrawl-2.6.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for pycrawl-2.6.0.tar.gz
Algorithm Hash digest
SHA256 d502edef7d8c540c9da71d2aadee5eaa5fe8de0260fb00b9c71f719a5065d73d
MD5 abae0a0523a114d2fb2404854891ffcc
BLAKE2b-256 91de19f89344cb24d6822b47f093ac65253fe729983304ab385e9b4b778708a0

See more details on using hashes here.

File details

Details for the file pycrawl-2.6.0-py3.8.egg.

File metadata

  • Download URL: pycrawl-2.6.0-py3.8.egg
  • Upload date:
  • Size: 8.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.6

File hashes

Hashes for pycrawl-2.6.0-py3.8.egg
Algorithm Hash digest
SHA256 7dec1370387cb8a35032616a50a4dbe2f2fcd98c26b8d34c6c0f865f39089921
MD5 f0145e12dc1c897cbf74993e0d87189b
BLAKE2b-256 5b70aaee793f21dddc52680e7d7a099f75c835f9685dbe8ce58177e30023d7c4

See more details on using hashes here.

File details

Details for the file pycrawl-2.6.0-py3-none-any.whl.

File metadata

  • Download URL: pycrawl-2.6.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for pycrawl-2.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6df435a44ff0f1595ff5e926b954a9c864dbfe94bf931bf797e465816c920088
MD5 3ed45bef3aeebe839f414e7381ef7a63
BLAKE2b-256 7e5ff933f1c2dbb18d575f657e69f41e9ba4b720ec94896ec6d3dbd5cffa5504

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page