Skip to main content

A secure python library for fetching data with async, JS, and Tor support

Project description

PyGrab

PyGrab is a simple and performant Python library for making HTTP requests written in rust. It is designed to be fully interoperable with the popular requests package in Python.

References

Features

  • Simple: PyGrab's API is designed to be straightforward and easy to use. If you're familiar with requests, you'll feel right at home.
  • Flexible: Whether you need to make a simple GET request, post data to a server, or download a file, PyGrab has you covered.
  • Performant: With its Rust-powered backend, PyGrab offers enhanced performance for CPU-bound tasks, providing faster data decompression, thread handling, and network handling.
  • Asynchronous Support: PyGrab includes functions for making asynchronous HTTP requests, allowing you to efficiently grab data from multiple URLs at once.
  • JavaScript Support: PyGrab can render JavaScript-enabled websites, allowing you to grab data from dynamic web pages.
  • Interface with Tor Network: PyGrab includes built-in support for routing requests through the tor network.
  • Automated IP Rotation: PyGrab includes built-in support for rotating connections to the Tor Network.

Limitations

  • PyGrab is only supported on windows an linux currently.

Installation

You can install PyGrab using pip:

pip install pygrab

Usage

Here's a simple example of how to use PyGrab to make a GET request:

import pygrab

response = pygrab.get('http://example.com')
print(response.text)

In this example, response is syntactically similar to the requests.Response object. You can use it just like you would in requests.

Here's an example of how to use PyGrab to make asynchronous GET requests through the Tor Network:

import pygrab

pygrab.Tor.start_tor()

urls = ['http://example.com', 'http://example.org', 'http://example.net']
responses = pygrab.get_batch(urls)

for response in responses.values():
    print(response.text)

In this example, responses is a dictionary of urls matched to their respective pygrab.HttpResponse objects. Each response corresponds to the URL at the same index in the urls list.

We can also use pygrab with python's async/await syntax.

async def grab_data():
    res = await pygrab.get_async('https://www.google.com')
    return res

Contributing

Contributions are welcome. Please submit a pull request with any improvements.

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

pygrab-3.1.1.tar.gz (5.4 MB view details)

Uploaded Source

Built Distribution

pygrab-3.1.1-py3-none-any.whl (5.4 MB view details)

Uploaded Python 3

File details

Details for the file pygrab-3.1.1.tar.gz.

File metadata

  • Download URL: pygrab-3.1.1.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for pygrab-3.1.1.tar.gz
Algorithm Hash digest
SHA256 7ea7a336bbbecfd17edad43da57e91c79f3263a367d24c7fcf82022137096477
MD5 f9e091bb06846fad16d54af46b0d41b6
BLAKE2b-256 5d19edbfeb0e1b4e73b609c48c473060453bfbf3c86c4a2f3be67f370479e7d8

See more details on using hashes here.

File details

Details for the file pygrab-3.1.1-py3-none-any.whl.

File metadata

  • Download URL: pygrab-3.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for pygrab-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08f40170ff513ab86bd8032fd849cbc8a1aca4cf00dfa08d25c0c231b359f845
MD5 3f361f28c9027da11adf383186d7404e
BLAKE2b-256 8d5a3799a61fde72ea7f76c96764e419ed5dce7963801534b2df0e277eab6067

See more details on using hashes here.

Supported by

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