0

I have some problem with reading some urls.

I try to use answer from this question Using an HTTP PROXY - Python but it didn't help and I get an error urllib2.URLError: <urlopen error [Errno 10060]

I have a list of url

yandex.ru/search?text=авито&lr=47
yandex.ru/search?text=цветок%20киддиленд%20музыкальный&lr=47
dns-shop.ru/product/c7bf1138670f3361/rul-hori-racing-wheel
dns-shop.ru/product/c7bf1138670f3361/rul-hori-racing-wheel#opinion
kaluga.onlinetrade.ru/catalogue/ruli_dgoystiki_geympadi-c31/hori/reviews/rul_hori_racing_wheel_controller_ps_4_ps4_020e_acps440-274260.html
kazan.onlinetrade.ru/catalogue/ruli_dgoystiki_geympadi-c31/hori/reviews/rul_hori_racing_wheel_controller_xboxone_xbox_005u_acxone34-274261.html
ebay.com

And code looks like

for url in urls:
    proxy = urllib2.ProxyHandler({"http":"http://61.233.25.166:80"})
    opener = urllib2.build_opener(proxy)
    urllib2.install_opener(opener)
    try:
        html = urllib2.urlopen(url).read()
    except ValueError or urllib2:
        url = 'http://www.' + url
        html = urllib2.urlopen(url).read()

Also I try

s = requests.Session()
s.proxies = {"http": "http://61.233.25.166:80"}

for url in urls:
     url = 'http://www.' + url
     r = s.get(url)
     print(r.text)

And it returns me

requests.exceptions.ProxyError: HTTPConnectionPool(host='61.233.25.166', port=80): Max retries exceeded with url: http://www.yandex.ru/search?text=%D0%B8%D0%B3%D1%80%D1%83%D1%88%D0%BA%D0%B0%20%22%D0%B2%D0%B5%D1%81%D0%B5%D0%BB%D0%B0%D1%8F%20%D0%B3%D1%83%D1%81%D0%B5%D0%BD%D0%B8%D1%86%D0%B0%22%20keenway%20%D0%BE%D1%82%D0%B7%D1%8B%D0%B2%D1%8B&lr=47 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x047D1090>: Failed to establish a new connection: [Errno 10060] \xcf\xee\xef\xfb\xf2\xea\xe0 \xf3\xf1\xf2\xe0\xed\xee\xe2\xe8\xf2\xfc \xf1\xee\xe5\xe4\xe8\xed\xe5\xed\xe8\xe5 \xe1\xfb\xeb\xe0 \xe1\xe5\xe7\xf3\xf1\xef\xe5\xf8\xed\xee\xe9, \xf2.\xea. \xee\xf2 \xe4\xf0\xf3\xe3\xee\xe3\xee \xea\xee\xec\xef\xfc\xfe\xf2\xe5\xf0\xe0 \xe7\xe0 \xf2\xf0\xe5\xe1\xf3\xe5\xec\xee\xe5 \xe2\xf0\xe5\xec\xff \xed\xe5 \xef\xee\xeb\xf3\xf7\xe5\xed \xed\xf3\xe6\xed\xfb\xe9 \xee\xf2\xea\xeb\xe8\xea, \xe8\xeb\xe8 \xe1\xfb\xeb\xee \xf0\xe0\xe7\xee\xf0\xe2\xe0\xed\xee \xf3\xe6\xe5 \xf3\xf1\xf2\xe0\xed\xee\xe2\xeb\xe5\xed\xed\xee\xe5 \xf1\xee\xe5\xe4\xe8\xed\xe5\xed\xe8\xe5 \xe8\xe7-',)))

Where is error there?

Community
  • 1
  • 1
  • Well it says in the error message `Caused by ProxyError('Cannot connect to proxy.'` and your proxy returns `Time to live exceeded` to ping.. – Baris Demiray Sep 14 '16 at 08:24
  • @BarisDemiray I have tried not this way to solve my problem. I also try `urllib2` and now `proxy_info = { 'user': 'login', 'pass': 'passwd', 'host': "proxyaddress", 'port': 8080 } proxy_support = urllib2.ProxyHandler({"http": "http://%(user)s:%(pass)s@%(host)s:%(port)d" % proxy_info}) opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)` but it returns me `urllib2.URLError: `. I can't understand, where an error: in proxy, that I specify or in type of url? – Евгений Цаплин Sep 14 '16 at 08:32

1 Answers1

0

Some of proxies didn't work. And I use urllib instead urllib2 and

for url in urls:
    proxies = {'http': 'http://109.172.106.3:9999', 'http': 'http://62.113.208.183:3128', 'http': 'http://178.22.148.122:3129', 'http': 'http://217.17.46.162:3128'}
    url = 'http://www.' + url
    html = urllib.urlopen(url, proxies=proxies).read()

And it works for me