Legacy Phantomjs Crawler
Pricing
Pay per usage
Go to Store
Legacy Phantomjs Crawler
5.0 (1)
Pricing
Pay per usage
5
Total users
3
Monthly users
2
Runs succeeded
>99%
Last modified
a year ago
You can access the Legacy Phantomjs Crawler programmatically from your own 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 token4// Replace the '<YOUR_API_TOKEN>' with your token5const client = new ApifyClient({6 token: '<YOUR_API_TOKEN>',7});8
9// Prepare Actor input10const input = {11 "startUrls": [12 {13 "key": "START",14 "value": "https://www.example.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 "pageFunction": function pageFunction(context) {25 // called on every page the crawler visits, use it to extract data from it26 var $ = context.jQuery;27 var result = {28 title: $('title').text(),29 myValue: $('TODO').text()30 };31 return result;32 },33 "interceptRequest": function interceptRequest(context, newRequest) {34 // called whenever the crawler finds a link to a new page,35 // use it to override default behavior36 return newRequest;37 }38};39
40// Run the Actor and wait for it to finish41const run = await client.actor("apify/legacy-phantomjs-crawler").call(input);42
43// Fetch and print Actor results from the run's dataset (if any)44console.log('Results from dataset');45console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);46const { items } = await client.dataset(run.defaultDatasetId).listItems();47items.forEach((item) => {48 console.dir(item);49});50
51// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Legacy Phantomjs Crawler API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use Legacy Phantomjs Crawler 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: