プロキシの設定はしており、urllibにも設定はしたのにも関わらず、エラーがでます。 どなたか回避策を教えて下さい。 (内部リンクを取得するプログラム)
python
1import csv 2from urllib.request import urlopen 3from bs4 import BeautifulSoup 4from urllib.error import HTTPError 5from urllib.parse import urlparse 6import re 7import datetime 8import random 9def get_page(url,max_page,max_depth): 10 proxy = urllib.request.ProxyHandler({'http': 'http://proxy.sample.com:80'}) 11 opener = urllib.request.build_opener(proxy) 12 urllib.request.install_opener(opener) 13 includeurl=[] 14 includeurl.append(url) 15 try: 16 while len(includeurl)<=max_page: 17 res = urlopen(url) 18 soup=BeautifulSoup(res.read(),"lxml") 19 for i.attrs['href'] in soup.select('[href^=url]'): 20 if i.attrs['href'] not in includeurl: 21 includurl.append(i.attrs['href']) 22 return includeurl 23 except HTTPError as e: 24 print("The server could not work!") 25 return "" 26 27 28 29 30 31 32 33 34 35urllib.error.URLError: <urlopen error [WinError 10060] 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接 続済みのホストが応答しなかったため、確立された接続は失敗しました。>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。