Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Using a Proxy Server
#1
Please consider the following python program.
import requests

url = 'https://washingtonpost.com/'

proxy = {
        "https": "https://202.29.237.212:3128",
        "http": "http://202.29.237.212:3128"
}

text = requests.get(url, proxies=proxy)
# text = requests.get(url)

output = open("out.html", "w")

output.write(text.text)

output.close()
When I run the program, it dies on the call to get with the following error messages:
ProxyError: HTTPSConnectionPool(host='www.washingtonpost.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x000001BC70C2FE48>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',)))

However, if I do not use the proxy server it works. What am I doing wrong?
Thanks,
Bob
Quote
#2
(Jul-15-2020, 01:11 PM)rsherry8 Wrote: However, if I do not use the proxy server it works. What am I doing wrong?
It's most likely the proxy that's has gone down,i get same error.
Here a test with another proxy,i just used list here
No error and it save.
import requests

url = 'https://washingtonpost.com/'

proxy = {
        "http": "167.71.91.204:80"
}

text = requests.get(url, proxies=proxy)
# text = requests.get(url)

output = open("out.html", "w")
output.write(text.text)
output.close()
Quote
#3
snippsat,

Thanks for the response and your code does work for me. What I am wondering is, how long do these proxy servers stay up? Do I need to change the proxy server every day?

Bob
Quote
#4
Free proxies can be unstable and not stay up so long.
Can look at this list
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Proxy Variable in Selenium wont work with FireFox Profile Proxy Setting. MIPython 0 5,795 Jul-13-2018, 05:43 PM
Last Post: MIPython

Forum Jump:


Users browsing this thread: 1 Guest(s)