My Actor 32
Pay $1.00 for 1,000 results
This Actor may be unreliable while under maintenance. Would you like to try a similar Actor instead?
See alternative ActorsMy Actor 32
Pay $1.00 for 1,000 results
You can access the My Actor 32 programmatically from your own JavaScript 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 token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11 "runMode": "DEVELOPMENT",
12 "startUrls": [
13 {
14 "url": "https://apify.com"
15 }
16 ],
17 "globs": [],
18 "linkSelector": "a[href]",
19 "pseudoUrls": [
20 {
21 "purl": "https://apify.com[(/[\\w-]+)?]"
22 }
23 ],
24 "pageFunction": `// The function accepts a single argument: the "context" object.
25 // For a complete list of its properties and functions,
26 // see https://apify.com/apify/web-scraper#page-function
27 async function pageFunction(context) {
28 // This statement works as a breakpoint when you're trying to debug your code. Works only with Run mode: DEVELOPMENT!
29 // debugger;
30
31 // jQuery is handy for finding DOM elements and extracting data from them.
32 // To use it, make sure to enable the "Inject jQuery" option.
33 const $ = context.jQuery;
34 const pageTitle = $('title').first().text();
35
36 // Print some information to actor log
37 context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);
38
39 // Manually add a new page to the queue for scraping.
40 await context.enqueueRequest({ url: 'http://www.example.com' });
41
42 // Return an object with the data extracted from the page.
43 // It will be stored to the resulting dataset.
44 return {
45 url: context.request.url,
46 pageTitle
47 };
48 }`,
49 "proxyConfiguration": {
50 "useApifyProxy": true
51 },
52 "initialCookies": [],
53 "waitUntil": [
54 "networkidle2"
55 ],
56 "preNavigationHooks": `// We need to return array of (possibly async) functions here.
57 // The functions accept two arguments: the "crawlingContext" object
58 // and "gotoOptions".
59 [
60 async (crawlingContext, gotoOptions) => {
61 // ...
62 },
63 ]`,
64 "postNavigationHooks": `// We need to return array of (possibly async) functions here.
65 // The functions accept a single argument: the "crawlingContext" object.
66 [
67 async (crawlingContext) => {
68 // ...
69 },
70 ]`,
71 "breakpointLocation": "NONE",
72 "customData": {}
73};
74
75// Run the Actor and wait for it to finish
76const run = await client.actor("honzakirchner43/my-actor-32").call(input);
77
78// Fetch and print Actor results from the run's dataset (if any)
79console.log('Results from dataset');
80console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
81const { items } = await client.dataset(run.defaultDatasetId).listItems();
82items.forEach((item) => {
83 console.dir(item);
84});
85
86// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
My Actor 32 API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use My Actor 32 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:
Actor Metrics
1 monthly user
-
1 star
59% runs succeeded
Created in May 2024
Modified 12 days ago