SDKs overview
ScrapingDog offers a suite of official SDKs and direct API integration options to facilitate web scraping tasks. These SDKs are designed to abstract the underlying HTTP requests and response handling, allowing developers to interact with the ScrapingDog API using native language constructs. The primary objective of these libraries is to simplify access to features such as proxy rotation, CAPTCHA bypassing, and JavaScript rendering, which are fundamental to effective web data extraction.
The SDKs are available for popular programming languages including Python, Node.js, PHP, Ruby, and Go. Each SDK provides methods to construct requests, pass parameters like target URLs and proxy settings, and parse the returned data. While official SDKs are provided for several languages, direct HTTP requests via clients like cURL are also fully supported, offering flexibility for environments where a dedicated SDK might not be preferred or available. The ScrapingDog documentation provides detailed examples for each supported language, demonstrating how to integrate the API for various use cases, from basic HTML retrieval to complex JavaScript-rendered page scraping.
These tools are particularly useful for developers who need to perform large-scale data collection or bypass advanced anti-bot measures without managing proxy infrastructure or headless browser environments manually. The SDKs handle these complexities internally, presenting a simplified interface to the developer.
Official SDKs by language
ScrapingDog provides official SDKs for several programming languages, each designed to streamline the integration process. These SDKs encapsulate the logic for making API calls, handling parameters, and processing responses, reducing the boilerplate code required for web scraping tasks. The core functionality across all SDKs includes the ability to specify a target URL, enable JavaScript rendering, manage proxy settings, and retrieve various data types.
The following table outlines the official SDKs, their respective package names, installation commands, and general maturity status based on their presence and support in the official documentation:
| Language | Package/Method | Installation Command | Maturity |
|---|---|---|---|
| Python | requests library (direct API calls) |
pip install requests |
Stable (via standard HTTP client) |
| Node.js | axios or node-fetch (direct API calls) |
npm install axios or npm install node-fetch |
Stable (via standard HTTP client) |
| PHP | GuzzleHttp/guzzle (direct API calls) |
composer require guzzlehttp/guzzle |
Stable (via standard HTTP client) |
| Ruby | Net::HTTP (direct API calls) |
Built-in to Ruby | Stable (via standard HTTP client) |
| Go | net/http (direct API calls) |
Built-in to Go | Stable (via standard HTTP client) |
It is important to note that while ScrapingDog provides extensive code examples for these languages, it primarily leverages standard HTTP client libraries rather than proprietary SDK packages. This approach ensures compatibility with widely used tools and practices within each language ecosystem. For instance, in Python, the requests library is commonly used for making HTTP requests, as detailed in the Python Requests documentation. Similarly, Node.js developers often utilize axios or node-fetch for API interactions, which are both well-documented and maintained.
This strategy allows developers to use familiar tools and patterns, minimizing the learning curve associated with integrating the ScrapingDog API.
Installation
Installation of the necessary components for interacting with the ScrapingDog API typically involves installing standard HTTP client libraries for your chosen programming language. Since ScrapingDog emphasizes direct API calls with comprehensive code examples rather than proprietary SDK packages, the installation process aligns with common practices for integrating external services.
Python
To use Python with ScrapingDog, the requests library is recommended for making HTTP requests. Install it using pip:
pip install requests
Node.js
For Node.js applications, axios or node-fetch are popular choices for HTTP client functionality. Install either using npm:
npm install axios
# or
npm install node-fetch
PHP
PHP projects often use Guzzle for robust HTTP client capabilities. Install it via Composer:
composer require guzzlehttp/guzzle
Ruby
Ruby includes the Net::HTTP library as part of its standard library, so no additional installation is typically required for basic HTTP requests. For more advanced features, gems like httparty or faraday can be installed via Bundler:
gem install httparty
# or
gem install faraday
Go
Go's standard library provides the net/http package for making HTTP requests, which is sufficient for interacting with the ScrapingDog API. No external installation is needed.
After installing the respective HTTP client libraries, developers can follow the ScrapingDog API documentation to construct requests with their API key and desired parameters. The API key is essential for authentication with the ScrapingDog service and is typically included as a query parameter in each request.
Quickstart example
This quickstart example demonstrates how to perform a basic web scrape using the ScrapingDog API with Python, retrieving the HTML content of a target URL. This example assumes you have Python and the requests library installed.
Python Quickstart
First, ensure you have the requests library installed:
pip install requests
Next, create a Python script (e.g., scrape_example.py) and add the following code. Replace YOUR_API_KEY with your actual ScrapingDog API key, which can be obtained from your ScrapingDog dashboard.
import requests
def scrape_website(api_key, url_to_scrape):
api_url = f"https://api.scrapingdog.com/scrape?api_key={api_key}&url={url_to_scrape}"
try:
response = requests.get(api_url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
print(f"Status Code: {response.status_code}")
print("--- Scraped Content (first 500 chars) ---")
print(response.text[:500]) # Print first 500 characters of the HTML
# You can process the full HTML content (response.text) here
# For example, using BeautifulSoup for parsing:
# from bs4 import BeautifulSoup
# soup = BeautifulSoup(response.text, 'html.parser')
# print(soup.title.string)
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
# Replace with your actual API key and the URL you want to scrape
my_api_key = "YOUR_API_KEY"
target_url = "https://httpbin.org/html"
scrape_website(my_api_key, target_url)
To run the script, execute it from your terminal:
python scrape_example.py
This script constructs a URL for the ScrapingDog API, including your API key and the target URL. It then makes a GET request and prints the HTTP status code and the first 500 characters of the returned HTML content. For more complex scraping scenarios, such as enabling JavaScript rendering or using specific proxy settings, additional parameters can be added to the API request URL, as detailed in the ScrapingDog API documentation.
Community libraries
As of the latest review of the ScrapingDog documentation and public repositories, ScrapingDog primarily supports integration through direct API calls using standard HTTP client libraries across various programming languages. The focus is on providing comprehensive code examples and clear instructions for these standard integrations rather than developing or promoting dedicated, language-specific SDKs or community-contributed libraries.
This approach allows developers to use familiar and widely adopted HTTP clients (e.g., Python's requests, Node.js's axios, PHP's Guzzle, Go's net/http, and Ruby's Net::HTTP) to interact with the API. The benefit of this strategy is that it reduces dependency on a specific vendor-supplied library, potentially offering greater flexibility and control to developers who prefer to work with established, well-maintained community-supported HTTP clients. For example, the Fetch API is a standard interface for fetching resources across the network, commonly used in web development.
While there are no officially endorsed community-specific SDKs listed, developers are free to build wrappers or helper libraries around the ScrapingDog API using the provided documentation. Such community efforts typically emerge organically based on user needs and contributions to public platforms like GitHub. However, any such libraries would be unofficial and would not be maintained or supported by ScrapingDog directly. Developers should exercise due diligence when using third-party community libraries, verifying their source, maintenance status, and security practices.
For most use cases, the official code examples and the direct API approach are sufficient for integrating ScrapingDog's capabilities into applications. The ScrapingDog documentation serves as the primary resource for all integration details, offering guidance on various parameters and functionalities, including JavaScript rendering, proxy settings, and handling different response formats.