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.
1import { ApifyClient } from 'apify-client';2
3// Initialize the ApifyClient with your Apify API token4// Replace the '<YOUR_API_TOKEN>' with your token5const client = new ApifyClient({6 token: '<YOUR_API_TOKEN>',7});8
9// Prepare Actor input10const input = {11 "startUrls": [12 {13 "url": "https://apify.com"14 }15 ],16 "linkSelector": "a[href]",17 "pseudoUrls": [18 {19 "purl": "https://apify.com[(/[\\w-]+)?]"20 }21 ],22 "pageFunction": // The function accepts a single argument: the "context" object.23 // For a complete list of its properties and functions,24 // see https://apify.com/apify/web-scraper#page-function 25 async function pageFunction(context) {26 // jQuery is handy for finding DOM elements and extracting data from them.27 // To use it, make sure to enable the "Inject jQuery" option.28 const $ = context.jQuery;29 const pageTitle = $('title').first().text();30 31 // Print some information to actor log32 context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);33 34 // Manually add a new page to the queue for scraping.35 // To make this work, make sure the "Use request queue" option is enabled.36 context.enqueueRequest({ url: 'http://www.example.com' });37 38 // Return an object with the data extracted from the page.39 // It will be stored to the resulting dataset.40 return {41 url: context.request.url,42 pageTitle43 };44 },45 "proxyConfiguration": {46 "useApifyProxy": false47 },48 "initialCookies": [],49 "waitUntil": [50 "networkidle2"51 ],52 "customData": {}53};54
55// Run the Actor and wait for it to finish56const run = await client.actor("rezaczu/testing-web-scraper").call(input);57
58// Fetch and print Actor results from the run's dataset (if any)59console.log('Results from dataset');60console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);61const { items } = await client.dataset(run.defaultDatasetId).listItems();62items.forEach((item) => {63 console.dir(item);64});65
66// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Testing web scraper API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use Testing web scraper API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.
Install the apify-client
$npm install apify-client
Other API clients include: