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 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 "startUrls": [{
10 "key": "START",
11 "value": "https://apify.com/",
12 }],
13 "crawlPurls": [{
14 "key": "MY_LABEL",
15 "value": "https://www.example.com/[.*]",
16 }],
17 "clickableElementsSelector": "a:not([rel=nofollow])",
18 "proxyConfiguration": { "useApifyProxy": True },
19 "pageFunction": """function pageFunction(context) {
20 // called on every page the crawler visits, use it to extract data from it
21 var $ = context.jQuery;
22 var result = {
23 title: $('title').text(),
24 myValue: $('TODO').text()
25 };
26 return result;
27}
28""",
29 "interceptRequest": """function interceptRequest(context, newRequest) {
30 // called whenever the crawler finds a link to a new page,
31 // use it to override default behavior
32 return newRequest;
33}
34""",
35}
36
37# Run the Actor and wait for it to finish
38run = client.actor("barry8schneider/legacy-phantomjs-crawler").call(run_input=run_input)
39
40# Fetch and print Actor results from the run's dataset (if there are any)
41print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
42for item in client.dataset(run["defaultDatasetId"]).iterate_items():
43 print(item)
44
45# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start
Phantom.js Scraper API in Python
The Apify API client for Python is the official library that allows you to use Phantom.js Scraper API in Python, providing convenience functions and automatic retries on errors.
Install the apify-client
pip install apify-client
Other API clients include: