Web Scraper Experimental Debug
Try for free
No credit card required
View all Actors
Web Scraper Experimental Debug
mtrunkat/web-scraper-experimental-dbgr
Try for free
No credit card required
Experimental version of Apify Web Scraper with Chrome debugger integrated
The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more
Node.js
Python
curl
1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5 token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10 "startUrls": [
11 {
12 "url": "https://apify.com"
13 }
14 ],
15 "pseudoUrls": [
16 {
17 "purl": "https://apify.com[(/[\\w-]+)?]"
18 }
19 ],
20 "linkSelector": "a",
21 "pageFunction": async function pageFunction(context) {
22 // See README for context properties. If the syntax is unfamiliar see the link
23 // https://javascript.info/destructuring-assignment#object-destructuring
24 const { request, log, jQuery } = context;
25
26 // To be able to use jQuery as $, one needs save it into a variable
27 // and select the inject jQuery option. We've selected it for you.
28 const $ = jQuery;
29 const title = $('title').text();
30
31 // This is yet another new feature of Javascript called template strings.
32 // https://javascript.info/string#quotes
33 log.info(`URL: ${request.url} TITLE: ${title}`);
34
35 // To save data just return an object with the requested properties.
36 return {
37 url: request.url,
38 title
39 };
40 },
41 "proxyConfiguration": {
42 "useApifyProxy": false
43 },
44 "initialCookies": [],
45 "waitUntil": [
46 "networkidle2"
47 ],
48 "customData": {}
49};
50
51(async () => {
52 // Run the Actor and wait for it to finish
53 const run = await client.actor("mtrunkat/web-scraper-experimental-dbgr").call(input);
54
55 // Fetch and print Actor results from the run's dataset (if any)
56 console.log('Results from dataset');
57 console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
58 const { items } = await client.dataset(run.defaultDatasetId).listItems();
59 items.forEach((item) => {
60 console.dir(item);
61 });
62})();
63
64// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Developer
Maintained by Community
Actor metrics
- 2 monthly users
- 89.7% runs succeeded
- 0.0 days response time
- Created in Oct 2019
- Modified about 3 years ago
Categories