Skip to main content

ScraperAPI Python SDK

Project description

ScraperAPI Python SDK

Install

pip install scraperapi-sdk

Usage

from scraperapi_sdk import ScraperAPIClient

client = ScraperAPIClient("<API-KEY>")

# regular get request
content = client.get('https://amazon.com/')
# get request with premium
content = client.get('https://amazon.com/', params={'premium': True})

# post request
content = client.post('https://webhook.site/403e44ce-5835-4ce9-a648-188a51d9395d', headers={'Content-Type': 'application/x-www-form-urlencoded'}, data={'field1': 'data1'})

# put request
content = client.put('https://webhook.site/403e44ce-5835-4ce9-a648-188a51d9395d', headers={'Content-Type': 'application/json'}, data={'field1': 'data1'})

The content variable will contain the scraped page.

If you want to get the Response object instead of the content you can use make_request.


response = client.make_request(url=https://webhook.site/403e44ce-5835-4ce9-a648-188a51d9395d', headers={'Content-Type': 'application/json'}, data={'field1': 'data1'})
# response will be <Response [200]>

Exception


from scraperapi_sdk import ScraperAPIClient
from scraperapi_sdk.exceptions import ScraperAPIException

client = ScraperAPIClient(
    api_key=api_key,
)
try:
    result = client.post('https://webhook.site/403e44ce-5835-4ce9-a648-188a51d9395d', headers={'Content-Type': 'application/x-www-form-urlencoded'}, data={'field1': 'data1'})
    _ = result
except ScraperAPIException as e:
    print(e.original_exception)  # you can access the original exception via `.original_exception` property.

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

scraperapi_sdk-1.0.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

scraperapi_sdk-1.0.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file scraperapi_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: scraperapi_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for scraperapi_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a2356627f4cd0e3fcfa045181b5a5059bcdfaab1c8286d3e212a7ffebd92ffbe
MD5 f5ab2bb7a8ed124f9e44a4d09e8ceb99
BLAKE2b-256 f23d5215d3cc09027d8e5419cdc3e50be4a68a42ed6639e8ba3841ba2e628813

See more details on using hashes here.

File details

Details for the file scraperapi_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: scraperapi_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for scraperapi_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a6bc17e5aa481204d48bd84a3a51503b8caddbe5654b7004dc55d6950eb1a36
MD5 37ccb4df5d5bf6f888a455afe3159025
BLAKE2b-256 47e27ce7ecaeecc090d6f2ed523ee1689a8b3fabc23dca7dcc6ea999da7363e9

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