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.

Structured Data Collection Methods

Amazon Endpoints

Amazon Product Page API

This method will retrieve product data from an Amazon product page and transform it into usable JSON.

result = client.amazon.product("<ASIN>")
result = client.amazon.product("<ASIN>", country="us", tld="com")

Read more in docs: Amazon Product Page API

Amazon Search API

This method will retrieve products for a specified search term from Amazon search page and transform it into usable JSON.

result = client.amazon.search("<QUERY>")
result = client.amazon.search("<QUERY>", country="us", tld="com")

Read more in docs: Amazon Search API

Amazon Offers API

This method will retrieve offers for a specified product from an Amazon offers page and transform it into usable JSON.

result = client.amazon.offers("<ASIN>")
result = client.amazon.offers("<ASIN>", country="us", tld="com")

Read more in docs: Amazon Offers API

Amazon Reviews API

This method will retrieve reviews for a specified product from an Amazon reviews page and transform it into usable JSON.

result = client.amazon.review("<ASIN>")
result = client.amazon.offers("<ASIN>", country="us", tld="com")

Read more in docs: Amazon Reviews API

Amazon Prices API

This method will retrieve product prices for the given ASINs and transform it into usable JSON.

result = client.amazon.prices(['<ASIN1>'])
result = client.amazon.prices(['<ASIN1>', '<ASIN2>'])
result = client.amazon.prices(['<ASIN1>', '<ASIN2>'], country="us", tld="com")

Read more in docs: Amazon Prices API

Google API

Google SERP API

This method will retrieve product data from an Google search result page and transform it into usable JSON.

result = client.google.search('free hosting')
result = client.google.search('free hosting', country="us", tld="com")

Read more in docs: Google SERP API

Google News API

This method will retrieve news data from an Google news result page and transform it into usable JSON.

result = client.google.news('tornado')
result = client.google.news('tornado', country="us", tld="com")

Read more in docs: Google News API

Google Jobs API

This method will retrieve jobs data from an Google jobs result page and transform it into usable JSON.

result = client.google.jobs('Senior Software Developer')
result = client.google.jobs('Senior Software Developer', country="us", tld="com")

Read more in docs: Google Jobs API

Google Shopping API

This method will retrieve shopping data from an Google shopping result page and transform it into usable JSON.

result = client.google.shopping('macbook air')
result = client.google.shopping('macbook air', country="us", tld="com")

Read more in docs: Google Shopping API

Walmart API

Walmart Search API

This method will retrieve product list data from Walmart as a result of a search.

result = client.walmart.search('hoodie')
result = client.walmart.search('hoodie', page=2)

Read more in docs: Walmart Search API

Walmart Category API

This method will retrieve Walmart product list for a specified product category.

result = client.walmart.category('5438_7712430_8775031_5315201_3279226')
result = client.walmart.category('5438_7712430_8775031_5315201_3279226', page=2)

Read more in docs: Walmart Category API

Walmart Product API

This method will retrieve Walmart product details for one product.

result = client.walmart.product('5053452213')

Read more in docs: Walmart Product API

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.3.0.tar.gz (3.6 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.3.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scraperapi_sdk-1.3.0.tar.gz
  • Upload date:
  • Size: 3.6 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.3.0.tar.gz
Algorithm Hash digest
SHA256 266853d2c25603206c09c58ba93eb40d362740c103195ba9948099fa98ab4acb
MD5 472af5d466849ab63ed422049571444e
BLAKE2b-256 1f6fc7f7c163826c4abc6d5d5ce753efd77bfbb2871e8d4dd7d20bd76ee84691

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scraperapi_sdk-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e57f656d602cfab594b74ce86e6c2ea25328eae57c0db93e13f4b87bdff0f42
MD5 3af6d64ae835494a068fb23639c8f429
BLAKE2b-256 edf587d73a25f91002c98551ad09c221404e5ac89e37ee67ad5de6ee9a93160f

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