Skip to content

Updated code to be compatible with Cookie Policy page #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LaurentMertens
Copy link

Upated upload_image.py so that when the first response is a "Accept/Reject cookie" page, the option "Reject all" is automatically selected.

…eject cookie" page, the option "Reject all" is automatically selected.
@FlorianMgs
Copy link

@LaurentMertens Thanks a lot, this fixed my issue!
@Vorrik can you please merge this? Thanks 🙏🏻

@Vorrik
Copy link
Owner

Vorrik commented Jun 23, 2024

Sorry for the late reply, will check soon

@Vorrik Vorrik self-requested a review June 23, 2024 15:39
@Vorrik
Copy link
Owner

Vorrik commented Jun 23, 2024

@FlorianMgs @LaurentMertens Could you try this
`
import requests

from http.cookiejar import DefaultCookiePolicy

s = requests.Session()

s.cookies.set_policy(DefaultCookiePolicy(blocked_domains=['consent.google.com']))

rev_img_searcher = ReverseImageSearcher(s)

res = rev_img_searcher.search(image_url)
`

@LaurentMertens
Copy link
Author

I get an error:

File "[...]/env/lib/python3.12/site-packages/google_img_source_search/image_uploader.py", line 21, in extract_image
id_2 = py_obj['ds:0']['request'][1][7][0]
~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

@Vorrik
Copy link
Owner

Vorrik commented Jun 25, 2024

I get an error:

File "[...]/env/lib/python3.12/site-packages/google_img_source_search/image_uploader.py", line 21, in extract_image
id_2 = py_obj['ds:0']['request'][1][7][0]

IndexError: list index out of range

Hmm, I haven't been able to get this error yet. What country? Do you use proxy? Does the problem appear in time of first search? Can you also send img url

@Temirln
Copy link

Temirln commented Jul 28, 2024

I get an error:

File "[...]/env/lib/python3.12/site-packages/google_img_source_search/image_uploader.py", line 21, in extract_image
id_2 = py_obj['ds:0']['request'][1][7][0]

IndexError: list index out of range

Hmm, I haven't been able to get this error yet. What country? Do you use proxy? Does the problem appear in time of first search? Can you also send img url

did you find the solution?
i had the same error

@LaurentMertens
Copy link
Author

LaurentMertens commented Jul 30, 2024

Still have the error... Here is the code i used:

from http.cookiejar import DefaultCookiePolicy

import requests
from google_img_source_search import ReverseImageSearcher

if name == 'main':
s = requests.Session()
s.cookies.set_policy(DefaultCookiePolicy(blocked_domains=['consent.google.com']))
rev_img_searcher = ReverseImageSearcher(s)
# res = rev_img_searcher.search('https://prod-images.tcm.com/Master-Profile-Images/frankenstein2931.75587.jpg')
res = rev_img_searcher.search('https://stoysnetcdn.com/tynt/tynttrdast50/tynttrdast50_4.jpg')

Tried two images, both gave the same error:

File "[...]/env/lib/python3.12/site-packages/google_img_source_search/image_uploader.py", line 21, in extract_image
id_2 = py_obj['ds:0']['request'][1][7][0]
~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

FWIW, I'm located in Belgium, no proxies.

EDIT: Using the Python debugger, I can see that the returned page from the Google request is the "Before you continue to Google" page. Potentially, this is a page we only get to see in Europe, with the GDPR laws?

@Vorrik
Copy link
Owner

Vorrik commented Aug 17, 2024

@LaurentMertens @FlorianMgs @Temirln @laumerte updated lib

@LaurentMertens
Copy link
Author

I reinstalled the repo, latest version 1.2.2, and still get the same problem.

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

Successfully merging this pull request may close these issues.

5 participants