Skip to content

Commit

Permalink
Merge pull request pkrumins#11 from Vort/parse_fix
Browse files Browse the repository at this point in the history
Fix tags parsing; avoid SSL: CERTIFICATE_VERIFY_FAILED error.
  • Loading branch information
kenorb committed Apr 27, 2016
2 parents 6f0ff5e + 11d3a1b commit dc6d951
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions xgoogle/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Code is licensed under MIT license.
#

import ssl
import random
import socket
import urllib
Expand Down Expand Up @@ -95,6 +96,8 @@ def __init__(self, user_agent=BROWSERS[0], debug=False, use_pool=False):
self.opener = urllib.request.build_opener(*self.handlers)
self.opener.addheaders = []

ssl._create_default_https_context = ssl._create_unverified_context

try:
conn = self.opener.open("http://www.google.com/ncr")
conn.info() # retrieve session cookie
Expand Down
4 changes: 2 additions & 2 deletions xgoogle/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _extract_info(self, soup):

def _extract_results(self, soup):
"""Extract results from the page"""
results = soup.findAll('li','g')
results = soup.findAll('div','g')
ret_res = []
for result in results:
eres = self._extract_result(result)
Expand Down Expand Up @@ -315,7 +315,7 @@ def _extract_title_url(self, result):

def _extract_description(self, result):
"""Seems this is enough"""
desc = result.find('div', {'class': 'st'})
desc = result.find('span', {'class': 'st'})
return desc

desc_div = result.find('span', 'st')
Expand Down

0 comments on commit dc6d951

Please sign in to comment.