Skip to content

Commit

Permalink
fixed get_news()
Browse files Browse the repository at this point in the history
  • Loading branch information
HurinHu committed Dec 13, 2023
1 parent 555def5 commit 6a475ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions GoogleNews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self,lang="en",period="",start="",end="",encode="utf-8",region=None
self.__end = end
self.__encode = encode
self.__exception = False
self.__version = '1.6.11'
self.__version = '1.6.12'

def getVersion(self):
return self.__version
Expand Down Expand Up @@ -282,7 +282,7 @@ def get_news(self, key="",deamplify=False):
try:
# title
try:
title=article.find('h4').text
title=article.findAll('div')[2].text
except:
title=None
# description
Expand All @@ -305,13 +305,13 @@ def get_news(self, key="",deamplify=False):
# link
if deamplify:
try:
link = 'news.google.com/' + article.find("h4").parent.get("href")[2:]
link = 'news.google.com/' + article.find('div').find("a").get("href")[2:]
except Exception as deamp_e:
print(deamp_e)
link = article.find("article").get("jslog").split('2:')[1].split(';')[0]
else:
try:
link = 'news.google.com/' + article.find("a").get("href")[2:]
link = 'news.google.com/' + article.find('div').find("a").get("href")[2:]
except Exception as deamp_e:
print(deamp_e)
link = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="GoogleNews",
version="1.6.11",
version="1.6.12",
author="Hurin Hu",
author_email="[email protected]",
description="Google News search for Python",
Expand Down
2 changes: 1 addition & 1 deletion test/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TestStringMethods(unittest.TestCase):

def testVersion(self):
googlenews = GoogleNews()
version = '1.6.11'
version = '1.6.12'
self.assertIn(version, googlenews.getVersion())
print('Latest version matched')

Expand Down

0 comments on commit 6a475ec

Please sign in to comment.