Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Migrate Process Newspaper3k

1 sites No security coverage Drupal 8–11
View on drupal.org

This module provides a tool to extract article data from web pages using the Newspaper3k Python library. It can retrieve and process information such as the article's text, title, images, keywords, and author.

Migrate Process Newspaper3k provides a Migrate process plugin to enable you to request and extract data from the python based Newspaper3k article download framework.

This plugin also works with Newspaper4k. Please note that newspaper4k schema is a little different. e.g. text key becomes _text

Newspaper3k Features

  1. Multi-threaded article download framework
  2. News url identification
  3. Text extraction from html
  4. Top image extraction from html
  5. All image extraction from html
  6. Keyword extraction from text
  7. Summary extraction from text
  8. Author extraction from text
  9. Google trending terms extraction
  10. Works in 10+ languages (English, Chinese, German, Arabic, …)

Prerequisites

LAMP server with python3 support.

See https://github.com/2dareis2do/newspaper3k-php-wrapper for installation and setup instructions.

Example Usage

process:
   'body/value':
     -
       plugin: migrate_process_js_redirect_link
       source: link
     -
       plugin: migrate_process_newspaper3k
     -
       plugin: skip_on_empty
       method: row
       message: 'migrate_process_newspaper3k import failed'
     -
       plugin: extract
       index:
         - summary

Schema Keys

See the included stub json for more info on this. Those of note include:

summary (string)
source_url (string)
url (string)
title (string)
top_img (string)
top_image (string)
meta_img (string)
imgs (array)
images (array)
movies (array)
text (string)
keywords (array)
meta_keywords (array)
tags (array)
authors (array)
publish_date (string)
summary (string)
html (string)
meta_data (array object)
meta_description (string)
article_html (string)
top_node (string)
doc (string)

DDEV support

If you are running ddev locally, to install newspaper3k and supporting libraries, you can add the following to your config.yaml found in your projects .ddev folder to install Newspaper3k and the necessary natural language data sets orcorpora.

Newspaper3k

hooks:
    post-start:
        - exec: 'pip3 install newspaper3k'
        - exec: 'curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python3'

Newspaper4k

hooks:
    post-start:
        - exec: 'pip3 install newspaper4k'
        - exec: 'pip3 install typing-extensions'
        - exec: 'pip3 install lxml_html_clean'

DDEV New (1.23)

webimage_extra_packages: [python3, python-is-python3, python3-pip, python3-typing-extensions]

hooks:
    post-start:
        - exec: 'pip3 install newspaper4k --break-system-packages'
        - exec: 'pip3 install lxml_html_clean --break-system-packages'

More info

For more info on how Newspaper3k parses articles please see https://newspaper.readthedocs.io/en/latest/user_guide/quickstart.html#pa...

Depends on

Dependencies of the latest stable release

  • migrate Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Sep 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 3
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.1.0 Stable 8–11 Feb 11, 2025
1.0.4 Stable 8–11 Oct 2, 2024
1.0.3 Stable 8–11 Sep 30, 2024