MarioVilas/googlesearch

tld `org` doesn't work

jdvala opened this issue · 1 comments

for website in search("en.une UNE 66926", tld="org",num=10, stop=3, pause=4):
    print(website)

Output

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-60-393ef278d240> in <module>()
      1 # UNE
----> 2 for website in search("en.une UNE 66926", tld="org",num=10, stop=3, pause=4):
      3     print(website)

~/miniconda3/envs/jay/lib/python3.6/site-packages/googlesearch/__init__.py in search(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params, tpe, user_agent)
    286 
    287         # Request the Google Search results page.
--> 288         html = get_page(url, user_agent)
    289 
    290         # Parse the response and process every anchored URL.

~/miniconda3/envs/jay/lib/python3.6/site-packages/googlesearch/__init__.py in get_page(url, user_agent)
    152     request.add_header('User-Agent', user_agent)
    153     cookie_jar.add_cookie_header(request)
--> 154     response = urlopen(request)
    155     cookie_jar.extract_cookies(response, request)
    156     html = response.read()

~/miniconda3/envs/jay/lib/python3.6/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    221     else:
    222         opener = _opener
--> 223     return opener.open(url, data, timeout)
    224 
    225 def install_opener(opener):

~/miniconda3/envs/jay/lib/python3.6/urllib/request.py in open(self, fullurl, data, timeout)
    530         for processor in self.process_response.get(protocol, []):
    531             meth = getattr(processor, meth_name)
--> 532             response = meth(req, response)
    533 
    534         return response

~/miniconda3/envs/jay/lib/python3.6/urllib/request.py in http_response(self, request, response)
    640         if not (200 <= code < 300):
    641             response = self.parent.error(
--> 642                 'http', request, response, code, msg, hdrs)
    643 
    644         return response

~/miniconda3/envs/jay/lib/python3.6/urllib/request.py in error(self, proto, *args)
    568         if http_err:
    569             args = (dict, 'default', 'http_error_default') + orig_args
--> 570             return self._call_chain(*args)
    571 
    572 # XXX probably also want an abstract factory that knows when it makes

~/miniconda3/envs/jay/lib/python3.6/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    502         for handler in handlers:
    503             func = getattr(handler, meth_name)
--> 504             result = func(*args)
    505             if result is not None:
    506                 return result

~/miniconda3/envs/jay/lib/python3.6/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    648 class HTTPDefaultErrorHandler(BaseHandler):
    649     def http_error_default(self, req, fp, code, msg, hdrs):
--> 650         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    651 
    652 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

The TLD in question is the one for Google, not for the sites you're trying to find. Since "google.org" does not exist your query is failing.