1

I try do use proxies for people also ask but it does not work.

import people_also_ask
import people_also_ask.request.session


username = "user"
password = "123456"
proxy = "pr.oxylabs.io:7777"

people_also_ask.request.session.set_proxies(
    (
        'http://{username}:{password}@{proxy}'
    )
)


a = people_also_ask.get_related_questions("coffee")

print (a)

I know this proxy provider work but i always get an error In my test Code I add the proxies like them.

##OxylabDaten########
username = "user"
password = "123456"
proxy = "pr.oxylabs.io:7777"

##Proxies#####

proxies = {
      'http': f'http://{username}:{password}@{proxy}',
      'https': f'http://{username}:{password}@{proxy}'
    }

r = requests.get(googlelink, headers=headers, proxies = proxies, verify=False) #r = requests.get('https://google.com/search?q=snap+7&num=100',headers=headers,)

Does anyone know how can I run people also ask with proxies and without errors.

This is the error message.

people_also_ask.exceptions.RequestError: ('https://www.google.com/search', {'q': 'coffee', 'gl': 'us'}, {'https': 'http://t'}, 'Traceback (most recent call last):\n File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn\n conn = connection.create_connection(\n File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection\n for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):\n File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo\n for res in _socket.getaddrinfo(host, port, family, type, proto, flags):\nsocket.gaierror: [Errno -2] Name or service not known\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 696, in urlopen\n self._prepare_proxy(conn)\n File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 966, in _prepare_proxy\n conn.connect()\n File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connect\n conn = self._new_conn()\n File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in _new_conn\n raise NewConnectionError(\nurllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f5025312190>: Failed to establish a new connection: [Errno -2] Name or service not known\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send\n resp = conn.urlopen(\n File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen\n retries = retries.increment(\n File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 574, in increment\n raise MaxRetryError(_pool, url, error or ResponseError(cause))\nurllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /search?q=coffee&gl=us (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5025312190>: Failed to establish a new connection: [Errno -2] Name or service not known')))\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/usr/local/lib/python3.9/dist-packages/people_also_ask/request/session.py", line 86, in get\n response = SESSION.get(\n File "/usr/lib/python3/dist-packages/requests/sessions.py", line 555, in get\n return self.request('GET', url, **kwargs)\n File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request\n resp = self.send(prep, **send_kwargs)\n File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send\n r = adapter.send(request, **kwargs)\n File "/usr/lib/python3/dist-packages/requests/adapters.py", line 510, in send\n raise ProxyError(e, request=request)\nrequests.exceptions.ProxyError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /search?q=coffee&gl=us (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5025312190>: Failed to establish a new connection: [Errno -2] Name or service not known')))\n')

I tried it with free proxy providers.

UpAndAdam
  • 4,515
  • 3
  • 28
  • 46

0 Answers0