Testing web scraper
Deprecated
Pricing
$10.00 / 1,000 results
Go to Store
Testing web scraper
Deprecated
The scraper of Web
0.0 (0)
Pricing
$10.00 / 1,000 results
0
Total users
2
Monthly users
2
Last modified
3 months ago
You can access the Testing web scraper programmatically from your own applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.
1from apify_client import ApifyClient2
3# Initialize the ApifyClient with your Apify API token4# Replace '<YOUR_API_TOKEN>' with your token.5client = ApifyClient("<YOUR_API_TOKEN>")6
7# Prepare the Actor input8run_input = {9 "startUrls": [{ "url": "https://apify.com" }],10 "linkSelector": "a[href]",11 "pseudoUrls": [{ "purl": "https://apify.com[(/[\\w-]+)?]" }],12 "pageFunction": """// The function accepts a single argument: the \"context\" object.13// For a complete list of its properties and functions,14// see https://apify.com/apify/web-scraper#page-function 15async function pageFunction(context) {16 // jQuery is handy for finding DOM elements and extracting data from them.17 // To use it, make sure to enable the \"Inject jQuery\" option.18 const $ = context.jQuery;19 const pageTitle = $('title').first().text();20
21 // Print some information to actor log22 context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);23
24 // Manually add a new page to the queue for scraping.25 // To make this work, make sure the \"Use request queue\" option is enabled.26 context.enqueueRequest({ url: 'http://www.example.com' });27
28 // Return an object with the data extracted from the page.29 // It will be stored to the resulting dataset.30 return {31 url: context.request.url,32 pageTitle33 };34}""",35 "proxyConfiguration": { "useApifyProxy": False },36 "initialCookies": [],37 "waitUntil": ["networkidle2"],38 "customData": {},39}40
41# Run the Actor and wait for it to finish42run = client.actor("rezaczu/testing-web-scraper").call(run_input=run_input)43
44# Fetch and print Actor results from the run's dataset (if there are any)45print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])46for item in client.dataset(run["defaultDatasetId"]).iterate_items():47 print(item)48
49# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start
Testing web scraper API in Python
The Apify API client for Python is the official library that allows you to use Testing web scraper API in Python, providing convenience functions and automatic retries on errors.
Install the apify-client
$pip install apify-client
Other API clients include: