Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions gsearch/googlesearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
try:
# Python 3
from urllib import request
from urllib import urlencode
from html.parser import HTMLParser # keep it to avoid warning
from html import unescape
from urllib.parse import quote, unquote
Expand All @@ -34,11 +35,9 @@ def download(query, num_results):
"""
downloads HTML after google search
"""
# https://stackoverflow.com/questions/11818362/how-to-deal-with-unicode-string-in-url-in-python3
name = quote(query)

name = name.replace(' ','+')
url = 'http://www.google.com/search?q=' + name
# Encode all characters
name = urlencode({"q": query})
url = 'http://www.google.com/search?' + name
if num_results != 10:
url += '&num=' + str(num_results) # adding this param might hint Google towards a bot
req = request.Request(url, headers={
Expand Down