Phantom.js Scraper avatar
Phantom.js Scraper
Deprecated
View all Actors
This Actor is deprecated

This Actor is unavailable because the developer has decided to deprecate it. Would you like to try a similar Actor instead?

See alternative Actors
Phantom.js Scraper

Phantom.js Scraper

barry8schneider/legacy-phantomjs-crawler

PhantomJS is 6 to 10 times faster than puppeteer per Compute Unit. Sends an email when the task is complete. The input screen has been improved. Note: PhantomJS is no longer being developed and might be detected and blocked by websites.

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

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            "key": "START",
13            "value": "https://apify.com/"
14        }
15    ],
16    "crawlPurls": [
17        {
18            "key": "MY_LABEL",
19            "value": "https://www.example.com/[.*]"
20        }
21    ],
22    "clickableElementsSelector": "a:not([rel=nofollow])",
23    "proxyConfiguration": {
24        "useApifyProxy": true
25    },
26    "pageFunction": function pageFunction(context) {
27        // called on every page the crawler visits, use it to extract data from it
28        var $ = context.jQuery;
29        var result = {
30            title: $('title').text(),
31            myValue: $('TODO').text()
32        };
33        return result;
34    },
35    "interceptRequest": function interceptRequest(context, newRequest) {
36        // called whenever the crawler finds a link to a new page,
37        // use it to override default behavior
38        return newRequest;
39    }
40};
41
42(async () => {
43    // Run the Actor and wait for it to finish
44    const run = await client.actor("barry8schneider/legacy-phantomjs-crawler").call(input);
45
46    // Fetch and print Actor results from the run's dataset (if any)
47    console.log('Results from dataset');
48    const { items } = await client.dataset(run.defaultDatasetId).listItems();
49    items.forEach((item) => {
50        console.dir(item);
51    });
52})();
Developer
Maintained by Community
Categories