Phantom.js Scraper
This Actor is unavailable because the developer has decided to deprecate it. Would you like to try a similar Actor instead?
See alternative ActorsPhantom.js Scraper
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.
You can access the Phantom.js Scraper 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 "startUrls": [
12 {
13 "key": "START",
14 "value": "https://apify.com/"
15 }
16 ],
17 "crawlPurls": [
18 {
19 "key": "MY_LABEL",
20 "value": "https://www.example.com/[.*]"
21 }
22 ],
23 "clickableElementsSelector": "a:not([rel=nofollow])",
24 "proxyConfiguration": {
25 "useApifyProxy": true
26 },
27 "pageFunction": function pageFunction(context) {
28 // called on every page the crawler visits, use it to extract data from it
29 var $ = context.jQuery;
30 var result = {
31 title: $('title').text(),
32 myValue: $('TODO').text()
33 };
34 return result;
35 },
36 "interceptRequest": function interceptRequest(context, newRequest) {
37 // called whenever the crawler finds a link to a new page,
38 // use it to override default behavior
39 return newRequest;
40 }
41};
42
43// Run the Actor and wait for it to finish
44const run = await client.actor("barry8schneider/legacy-phantomjs-crawler").call(input);
45
46// Fetch and print Actor results from the run's dataset (if any)
47console.log('Results from dataset');
48console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
49const { items } = await client.dataset(run.defaultDatasetId).listItems();
50items.forEach((item) => {
51 console.dir(item);
52});
53
54// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Phantom.js Scraper API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use Phantom.js Scraper 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: