Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readability of MSN articles #181

Open
rpdelaney opened this issue Dec 25, 2023 · 0 comments
Open

Readability of MSN articles #181

rpdelaney opened this issue Dec 25, 2023 · 0 comments

Comments

@rpdelaney
Copy link

I'm struggling to get this working with MSN news articles. Here's the approach I'm using:

def fetch_url(url: str, timeout: int = 10) -> str:
    """Get the content from a page at URL, if it is a URL."""
    if not is_url(url):
        return url

    response = requests.get(url, timeout=timeout)
    response.raise_for_status()
    soup = bs(response.content, "html.parser")

    return soup.get_text()


def summarize(content: str) -> str:
    """Take content and use readability to return a document summary."""
    doc = Document(content)

    title: str = doc.short_title()
    summary: str = bs(doc.summary(), "lxml").text

    return f"{title}\n{summary}"

This works well on all the other news sites I've tried, but with MSN it's different.

Example. With this URL, I only get MSN for a title and the summary is empty.

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant