Web Scraper new avatar
Web Scraper new

Under maintenance

Pricing

Pay per event

Go to Store
Web Scraper new

Web Scraper new

Under maintenance

Developed by

Jan Kirchner

Jan Kirchner

Maintained by Community

The scraper of Web

5.0 (1)

Pricing

Pay per event

1

Total users

3

Monthly users

3

Last modified

a month ago

You can access the Web Scraper new 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.

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": [{ "url": "https://apify.com" }],
10 "linkSelector": "a[href]",
11 "pseudoUrls": [{ "purl": "https://apify.com[(/[\\w-]+)?]" }],
12 "pageFunction": """// The function accepts a single argument: the \"context\" object.
13// For a complete list of its properties and functions,
14// see https://apify.com/apify/web-scraper#page-function
15async function pageFunction(context) {
16 // jQuery is handy for finding DOM elements and extracting data from them.
17 // To use it, make sure to enable the \"Inject jQuery\" option.
18 const $ = context.jQuery;
19 const pageTitle = $('title').first().text();
20
21 // Print some information to actor log
22 context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);
23
24 // Manually add a new page to the queue for scraping.
25 // To make this work, make sure the \"Use request queue\" option is enabled.
26 context.enqueueRequest({ url: 'http://www.example.com' });
27
28 // Return an object with the data extracted from the page.
29 // It will be stored to the resulting dataset.
30 return {
31 url: context.request.url,
32 pageTitle
33 };
34}""",
35 "proxyConfiguration": { "useApifyProxy": False },
36 "initialCookies": [],
37 "waitUntil": ["networkidle2"],
38 "customData": {},
39}
40
41# Run the Actor and wait for it to finish
42run = client.actor("honzakirchner43/web-scraper-new").call(run_input=run_input)
43
44# Fetch and print Actor results from the run's dataset (if there are any)
45print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
46for item in client.dataset(run["defaultDatasetId"]).iterate_items():
47 print(item)
48
49# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

Web Scraper new API in Python

The Apify API client for Python is the official library that allows you to use Web Scraper new API in Python, providing convenience functions and automatic retries on errors.

Install the apify-client

$pip install apify-client

Other API clients include: