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