Skip to content

Commit

Permalink
Solve issue ranahaani#70: return full text article
Browse files Browse the repository at this point in the history
  • Loading branch information
parth-lth committed Jun 10, 2024
1 parent a322163 commit 5e8875c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gnews/gnews.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ def country(self, country):

def get_full_article(self, url):
"""
Download an article from the specified URL, parse it, and return an article object.
Download an article from the specified URL, parse it, and return the full text of the article.
:param url: The URL of the article you wish to summarize.
:return: An `Article` object returned by the `newspaper3k` library if installed; otherwise, None.
:return: The full text of the article.
"""
try:
import newspaper
Expand All @@ -188,7 +188,12 @@ def get_full_article(self, url):
print(f"An error occurred while fetching the article: {error}")
return None

return article
if len(article.text) < 200: # Assuming that a complete article would have more than 200 characters
soup = Soup(article.html, 'html.parser')
full_text = soup.get_text()
return full_text.strip()

return article.text.strip()


@staticmethod
Expand Down

0 comments on commit 5e8875c

Please sign in to comment.