jarun / googler

:mag: Google from the terminal
GNU General Public License v3.0
6.11k stars 529 forks source link

Implement --ipv4, --ipv6 options #337

Closed zmwangx closed 4 years ago

zmwangx commented 4 years ago

Resolves #331.

Apparently forgot about this...

$ ./googler --debug -6 google
[DEBUG] googler version 4.1
[DEBUG] Python version 3.6.9
[DEBUG] Connecting to new host www.google.com
[DEBUG] Opened socket to [2607:f8b0:4006:801::2004]:443
[DEBUG] Fetching URL /search?ie=UTF-8&oe=UTF-8&q=google&sei=1_E8tJDwEeqCafI8kdi9aw
[DEBUG] Cookie: 1P_JAR=2020-05-08-05
Traceback (most recent call last):
...
__main__.GoogleConnectionError: Connection blocked due to unusual activity. If you are connecting over IPv6 (use --debug to view connection details), the -4, --ipv4 option might help. THIS IS NOT A BUG, please do NOT report it as a bug unless you have specific information that may lead to the development of a workaround. You IP address is temporarily or permanently blocked by Google and requires reCAPTCHA-solving to use the service, which googler is not capable of. Possible causes include issuing too many queries in a short time frame, or operating from a shared / low reputation IP with a history of abuse. Please do NOT use googler for automated scraping.
$ ./googler --debug -4 google
[DEBUG] googler version 4.1
[DEBUG] Python version 3.6.9
[DEBUG] Connecting to new host www.google.com
[DEBUG] Opened socket to 172.217.10.68:443
[DEBUG] Fetching URL /search?ie=UTF-8&oe=UTF-8&q=google&sei=6VbelpDwEeqCafI8kdi9aw
[DEBUG] Cookie: 1P_JAR=2020-05-08-05
[DEBUG] Response body written to '/tmp/googler-response-2crku6r9.html'.

 1.  Google
     https://www.google.com/
     Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're
     looking ...

...
zmwangx commented 4 years ago

For the record: tested on Windows already, no socket API incompatibilities there.

jarun commented 4 years ago

Thank you!