manashmandal / pygoogle

Automatically exported from code.google.com/p/pygoogle
0 stars 0 forks source link

Module usage in Python v3 #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. apply 2to3 to pygoogle.py
2. run script:
from pygoogle import pygoogle
g = pygoogle('quake 3 arena')
g.pages = 5
print(g.get_result_count())
print(g.get_urls()[0])

What is the expected output? What do you see instead?
Expected output: number of search results followed by a first result link
Seen output:

Traceback (most recent call last):
  File "somepath", line 4, in <module>
    print(g.get_result_count())
  File "C:\Python33\lib\site-packages\pygoogle.py", line 189, in get_result_coun
t
    search_results = self.__search__()
  File "C:\Python33\lib\site-packages\pygoogle.py", line 106, in __search__
    data = json.loads(search_results.read())#.decode('utf-8')) #by andervish 05.
05.2014
  File "C:\Python33\lib\json\__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "C:\Python33\lib\json\decoder.py", line 352, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: can't use a string pattern on a bytes-like object

What version of the product are you using? On what operating system?
using r7 revision of pygoogle.py installed with r2 setup.py

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit 
(AMD64)] on win32

Please provide any additional information below.

Suggested solution: on line 106 of pygoogle.py for Python3 change
            data = json.loads(search_results.read())
to
            data = json.loads(search_results.read().decode('utf-8'))

Original issue reported on code.google.com by Anderv...@gmail.com on 4 May 2014 at 11:41

GoogleCodeExporter commented 8 years ago
I have the same issue with python2.7

Original comment by dayemsid...@gmail.com on 24 Jul 2015 at 10:15