Skip to main content

No project description provided

Project description

PyCrawl

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)

# 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pycrawl-1.1.0-py3.7.egg (7.3 kB view details)

Uploaded Egg

pycrawl-1.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pycrawl-1.1.0-py3.7.egg.

File metadata

  • Download URL: pycrawl-1.1.0-py3.7.egg
  • Upload date:
  • Size: 7.3 kB
  • Tags: Egg
  • 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-1.1.0-py3.7.egg
Algorithm Hash digest
SHA256 7b78c1eaa16b716cbb8ab2445ba26464b6ab3f71201fc58973e46df9cedc56f0
MD5 d076c72a1c5b08c2688e7dd768f340d1
BLAKE2b-256 7eed9d7b10e47e271809ae78f248cd444d42a67a23277f4d7897932bba112ff4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycrawl-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for pycrawl-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 159af0598bdec529b8e14d8c392126b5e9202c7345abe42ada0428137eea9fce
MD5 b6b3c2064c9ce175f5552cfde0894151
BLAKE2b-256 9338ae8803e25e3464c81b74f0362a8f3495bdb7f316b9bee0f8885f3339950a

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