ScrapingBee Python SDK
Project description
ScrapingBee Python SDK
ScrapingBee is a web scraping API that handles headless browsers and rotates proxies for you. The Python SDK makes it easier to interact with ScrapingBee's API.
Installation
You can install ScrapingBee Python SDK with pip.
pip install scrapingbee
Usage
The ScrapingBee Python SDK is a wrapper around the requests library. ScrapingBee supports GET and POST requests.
Signup to ScrapingBee to get your API key and some free credits to get started.
Making a GET request
>>> from scrapingbee import ScrapingBeeClient
>>> client = ScrapingBeeClient(api_key='REPLACE-WITH-YOUR-API-KEY')
>>> response = client.get(
'https://www.scrapingbee.com/blog/',
params={
# Block ads on the page you want to scrape
'block_ads': False,
# Block images and CSS on the page you want to scrape
'block_ressources': True,
# Premium proxy geolocation
'country_code': '',
# Control the device the request will be sent from
'device': 'desktop',
# Use some data extraction rules
'extract_rules': {'title': 'h1'},
# Wrap response in JSON
'json_response': False,
# JavaScript snippet to execute (clicking on a button, scrolling ...)
'js_snippet': '',
# Scrolling to the end of the page before returning your results
'js_scroll': False,
# The time to wait between each scroll
'js_scroll_wait': 1000,
# The number of scrolls you want to make
'js_scroll_count': 1,
# Use premium proxies to bypass difficult to scrape websites (10-25 credits/request)
'premium_proxy': False,
# Execute JavaScript code with a Headless Browser (5 credits/request)
'render_js': True,
# Return the original HTML before the JavaScript rendering
'return_page_source': False,
# Transparently return the same HTTP code of the page requested.
'transparent_status_code': False,
# Wait, in miliseconds, before returning the response
'wait': 0,
# Wait for CSS selector before returning the response, ex ".title"
'wait_for': ''
},
headers={
# Forward custom headers to the target website
"key": "value"
},
cookies={
# Forward custom cookies to the target website
"name": "value"
}
)
>>> response.text
'<!DOCTYPE html><html lang="en"><head>...'
ScrapingBee takes various parameters to render JavaScript, execute a custom JavaScript script, use a premium proxy from a specific geolocation and more.
You can find all the supported parameters on ScrapingBee's documentation.
You can send custom cookies and headers like you would normally do with the requests library.
Using ScrapingBee with Scrapy
Scrapy is the most popular Python web scraping framework. You can easily integrate ScrapingBee's API with the Scrapy middleware.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for scrapingbee-1.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 797682af33148b34050fa2ecb018b81fdc0fe79ad484e8b86df2162280dd1fc9 |
|
MD5 | 332fd9c5106f921a126f21fb3e30e3de |
|
BLAKE2b-256 | 82dc04ceb9993324101f4490962b1ec967ab28c049ed0c9308ebbbf5cf171a31 |