Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
HurinHu committed Dec 26, 2022
2 parents 22d98fa + 3fc9228 commit b5931f6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions GoogleNews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,14 @@ def getpage(self, page=1):
def get_news(self, key="",deamplify=False):
if key != '':
key = "+".join(key.split(" "))
if self.__encode != "":
key = urllib.request.quote(key.encode(self.__encode))
self.url = 'https://news.google.com/search?q={}+when:{}&hl={}'.format(key,self.__period,self.__lang.lower())
# if period is set, add it to the query
if self.__period != "":
key += f"+when:{self.__period}"
self.url = 'https://news.google.com/search?q={}&hl={}'.format(key,self.__lang.lower())
else:
# if no query, users still can use period
if self.__period != "":
self.url += f"when:{self.__period}"
self.url = 'https://news.google.com/?hl={}'.format(self.__lang)
try:
self.req = urllib.request.Request(self.url, headers=self.headers)
Expand Down

0 comments on commit b5931f6

Please sign in to comment.