Articles from a URL
Fetch a public news page, keep only the article text, then tag it.
from neam import Neam
from neam.articles import extract_article_text
text, status = extract_article_text("https://example.com/news/some-article")
print(status) # Loaded 1,582 characters from the article.
result = Neam.from_pretrained("MoriartyPuth/neam").predict(text)extract_article_text(url, max_chars=20000) returns the article text and a short status message. The web app's Import an online article box uses the same function.
What it keeps
- The page's main article body, found through common news-site containers, falling back to
<main>or the page body. - Scripts, styles, navigation, headers, footers, forms and share buttons are dropped.
- On Khmer pages, non-Khmer lines before the first Khmer line and after the last one (menus and footers) are trimmed.
- The text is cut to
max_chars; the status says when that happened.
Safety checks
- Only complete
http://orhttps://addresses, without user names or passwords. - Every address, including each redirect, must resolve to a public internet address. Private and local networks are refused.
- At most five redirects, and at most 5 MB downloaded.
- Only HTML or plain-text responses.
Respect the publisher. News articles belong to their publishers. Tag them for your own analysis, but don't republish their text; Neam's own datasets store only positions, never article text.