Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list index out of range | KeyError: 'page' #68

Open
CoudPelle opened this issue Dec 12, 2021 · 4 comments
Open

list index out of range | KeyError: 'page' #68

CoudPelle opened this issue Dec 12, 2021 · 4 comments

Comments

@CoudPelle
Copy link

Trying to make it work on windows 10, python 3.9.9

Initially, I had no error prompted, just this output:

"name='NID', domain=None, path=None"
Received invalid response

After adding Exception and traceback printing to start function (line 163), I eventually noticed a strange issue with the self.head was not set in the rest of the program, even if I call resethead(), self.head still doesn't exist.

So I add a self.head definition in the init function of the class. Now I got an error similar as other issues reported here.

Traceback (most recent call last):
  File "C:\Users\Pelle\code\GoBooDo\GoBooDo.py", line 163, in start
    self.getInitialData()
  File "C:\Users\Pelle\code\GoBooDo\GoBooDo.py", line 94, in getInitialData
    stringResponse = ("["+scripts[-4].text.split("_OC_Run")[1][1:-2]+"]")
IndexError: list index out of range

I tried to replace the code as suggested in #60
but now I had this error log:

Traceback (most recent call last):
  File "C:\Users\Pelle\code\GoBooDo\GoBooDo.py", line 162, in start
    self.getInitialData()
  File "C:\Users\Pelle\code\GoBooDo\GoBooDo.py", line 95, in getInitialData
    self.createPageDict(jsonResponse)
  File "C:\Users\Pelle\code\GoBooDo\GoBooDo.py", line 74, in createPageDict
    for pageData in jsonResponse[0]['page']:
KeyError: 'page'

I don't know what the jsonResponse should be but I've printed it and there is no attribute "page".

@CoudPelle
Copy link
Author

As suggested to me, I've tried the fork made by memerememe but no change yet. I also tried different countries including mine in the settings.json (I'm in France).

@memerememe
Copy link

I saw a reply to on one of a similar issue raised in the issues page which said, using a vpn fixed it for them or using a proxy.txt file and setting the settings.conf "proxy_links" and "proxy_images" to 1.

Another proposed fix is also uncommenting the faulty line(however not recommended as possible "risky" as mentioned by the person):
#57

@CoudPelle
Copy link
Author

I tried it with a vpn for italy, germany and UK but the error has not changed.
I also tried the suggestion of #57 and It's test code give me an error :
Traceback (most recent call last):

  File "test.py", line 12, in <module>
    print(req.cookies['name'])
  File "/home/pl/.pyenv/versions/3.7.11/lib/python3.7/site-packages/requests/cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "/home/pl/.pyenv/versions/3.7.11/lib/python3.7/site-packages/requests/cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='name', domain=None, path=None"

When I comment the 58 line 'Cookie': "NID=" + str(req.cookies['NID']),
the output
"name='NID', domain=None, path=None"
is replaced by

{'Host': 'books.google.it', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.00', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'close'}

but It's still stucked on a KeyError: 'page'
I may specify that I tried those tests on both @vaibhavk97 and @memerememe versions, with same results.

@mrelg
Copy link

mrelg commented Feb 19, 2022

maybe this will help
#63 (comment)
req = requests.get("https://google."+self.country, cookies={'CONSENT': 'YES+1'}, verify=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants