Smart Article Extractor avatar
Smart Article Extractor
Try for free

No credit card required

View all Actors
Smart Article Extractor

Smart Article Extractor

lukaskrivka/article-extractor-smart
Try for free

No credit card required

📰 Smart Article Extractor extracts articles from any scientific, academic, or news website with just one click. The extractor crawls the whole website and automatically distinguishes articles from other web pages. Download your data as HTML table, JSON, Excel, RSS feed, and more.

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more

1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4client = ApifyClient("<YOUR_API_TOKEN>")
5
6# Prepare the Actor input
7run_input = {
8    "startUrls": [{ "url": "https://www.theguardian.com" }],
9    "isUrlArticleDefinition": {
10        "minDashes": 4,
11        "hasDate": True,
12        "linkIncludes": [
13            "article",
14            "storyid",
15            "?p=",
16            "id=",
17            "/fpss/track",
18            ".html",
19            "/content/",
20        ],
21    },
22    "proxyConfiguration": { "useApifyProxy": True },
23    "extendOutputFunction": """($) => {
24    const result = {};
25    // Uncomment to add a title to the output
26    // result.pageTitle = $('title').text().trim();
27
28    return result;
29}""",
30}
31
32# Run the Actor and wait for it to finish
33run = client.actor("lukaskrivka/article-extractor-smart").call(run_input=run_input)
34
35# Fetch and print Actor results from the run's dataset (if there are any)
36print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
37for item in client.dataset(run["defaultDatasetId"]).iterate_items():
38    print(item)
39
40# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start
Developer
Maintained by Apify
Actor metrics
  • 194 monthly users
  • 47 stars
  • 99.9% runs succeeded
  • 1.9 days response time
  • Created in Nov 2019
  • Modified 15 days ago
Categories