My Actr testing 2 avatar
My Actr testing 2
Try for free

No credit card required

View all Actors
My Actr testing 2

My Actr testing 2

xrhibiyftd/my-actr-testing-2
Try for free

No credit card required

Crawls websites with the headless Chrome and Puppeteer library using a provided server-side Node.js code. This crawler is an alternative to apify/web-scraper that gives you finer control over the process. Supports both recursive crawling and list of URLs. Supports login to website.

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 mode

Node.js

Python

curl

1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4client = ApifyClient("<YOUR_API_TOKEN>")
5
6# Prepare the Actor input
7run_input = {
8    "startUrls": [{ "url": "https://crawlee.dev" }],
9    "globs": [{ "glob": "https://crawlee.dev/*/*" }],
10    "pseudoUrls": [],
11    "excludes": [{ "glob": "/**/*.{png,jpg,jpeg,pdf}" }],
12    "linkSelector": "a",
13    "pageFunction": """async function pageFunction(context) {
14    const { page, request, log } = context;
15    const title = await page.title();
16    log.info(`URL: ${request.url} TITLE: ${title}`);
17    return {
18        url: request.url,
19        title
20    };
21}""",
22    "proxyConfiguration": { "useApifyProxy": True },
23    "initialCookies": [],
24    "waitUntil": ["networkidle2"],
25    "preNavigationHooks": """// We need to return array of (possibly async) functions here.
26// The functions accept two arguments: the \"crawlingContext\" object
27// and \"gotoOptions\".
28[
29    async (crawlingContext, gotoOptions) => {
30        const { page } = crawlingContext;
31        // ...
32    },
33]""",
34    "postNavigationHooks": """// We need to return array of (possibly async) functions here.
35// The functions accept a single argument: the \"crawlingContext\" object.
36[
37    async (crawlingContext) => {
38        const { page } = crawlingContext;
39        // ...
40    },
41]""",
42    "customData": {},
43}
44
45# Run the Actor and wait for it to finish
46run = client.actor("xrhibiyftd/my-actr-testing-2").call(run_input=run_input)
47
48# Fetch and print Actor results from the run's dataset (if there are any)
49for item in client.dataset(run["defaultDatasetId"]).iterate_items():
50    print(item)
Developer
Maintained by Community
Actor metrics
  • 6 monthly users
  • 100.0% runs succeeded
  • 0.0 days response time
  • Created in Jan 2024
  • Modified 3 months ago
Categories