Playwright Scraper avatar
Playwright Scraper

Pricing

Pay per usage

Go to Store
Playwright Scraper

Playwright Scraper

apify/playwright-scraper

Developed by

Apify

Maintained by Apify

Crawls websites with the headless Chromium, Chrome, or Firefox browser and Playwright library using a provided server-side Node.js code. Supports both recursive crawling and a list of URLs. Supports login to a website.

4.3 (7)

Pricing

Pay per usage

31

Monthly users

134

Runs succeeded

98%

Response time

13 days

Last modified

10 months ago

You can access the Playwright Scraper 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://crawlee.dev" }],
10    "globs": [{ "glob": "https://crawlee.dev/*/*" }],
11    "pseudoUrls": [],
12    "excludes": [{ "glob": "/**/*.{png,jpg,jpeg,pdf}" }],
13    "linkSelector": "a",
14    "pageFunction": """async function pageFunction(context) {
15    const { page, request, log } = context;
16    const title = await page.title();
17    log.info(`URL: ${request.url} TITLE: ${title}`);
18    return {
19        url: request.url,
20        title
21    };
22}""",
23    "proxyConfiguration": { "useApifyProxy": True },
24    "initialCookies": [],
25    "launcher": "chromium",
26    "waitUntil": "networkidle",
27    "preNavigationHooks": """// We need to return array of (possibly async) functions here.
28// The functions accept two arguments: the \"crawlingContext\" object
29// and \"gotoOptions\".
30[
31    async (crawlingContext, gotoOptions) => {
32        const { page } = crawlingContext;
33        // ...
34    },
35]""",
36    "postNavigationHooks": """// We need to return array of (possibly async) functions here.
37// The functions accept a single argument: the \"crawlingContext\" object.
38[
39    async (crawlingContext) => {
40        const { page } = crawlingContext;
41        // ...
42    },
43]""",
44    "customData": {},
45}
46
47# Run the Actor and wait for it to finish
48run = client.actor("apify/playwright-scraper").call(run_input=run_input)
49
50# Fetch and print Actor results from the run's dataset (if there are any)
51print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
52for item in client.dataset(run["defaultDatasetId"]).iterate_items():
53    print(item)
54
55# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

Playwright Scraper API in Python

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

Install the apify-client

pip install apify-client

Other API clients include:

Pricing

Pricing model

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage.