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