ScrapingBee is a web scraping API that handles headless browsers and rotates proxies for you. The Python SDK simplifies interaction with this API, offering features like JavaScript rendering, proxy rotation, AI-powered data extraction, and screenshot capabilities. It is currently at version 2.0.2 and receives regular updates, focusing on reliability and new API features.
pip install scrapingbeeVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the ScrapingBee client with an API key (preferably from an environment variable) and sends a GET request to a URL. It demonstrates using `extract_rules` to automatically parse specific data (title, subtitle, article headings) from the page into a JSON format.
Review your `params` dictionary and the target URLs to ensure they are correctly interpreted by the API's new encoding logic. Test existing scraping jobs thoroughly.
Upgrade your Python environment to version 3.8 or newer. Python 3.6 has reached its end-of-life and is no longer supported by the Python core team.
Retrieve your API key from an environment variable (e.g., `os.environ.get('SCRAPINGBEE_API_KEY')`) rather than embedding it directly in your code. Ensure this variable is set in your deployment environment.For pages that do not require JavaScript execution, set `render_js=False` in your `params` dictionary to save credits. E.g., `client.get(url, params={'render_js': False})`.Implement proper concurrency management in your scraping logic (e.g., using `concurrent.futures.ThreadPoolExecutor` in Python) to respect your plan's concurrent request limit.
Regularly monitor your scrapers and adjust `extract_rules` as needed when website layouts change. Consider using AI-powered extraction or a combination of robust selectors and post-processing for critical data.
Install the official ScrapingBee Python SDK using pip: `pip install scrapingbee-python-sdk`
Ensure you are using a valid and active API key from your ScrapingBee dashboard and pass it correctly: `client = ScrapingBeeClient(api_key='YOUR_VALID_API_KEY')`
Increase the timeout duration for your requests, both for the ScrapingBee API and potentially your local client: `response = client.get('https://example.com', params={'timeout': 60000}, timeout=45)`Always pass `javascript_scenario_steps` as a list of dictionaries, even if it contains only one step: `params={'javascript_scenario': True, 'javascript_scenario_steps': [{'click': '.some-button'}]}`Use the correct class name 'ScrapingBeeClient' in your import statement: `from scrapingbee import ScrapingBeeClient`