2017-05-30 21 views
-1

私はurllib.requestに長年にわたる問題があります。私は何をすべきか: urllib.request.urlopen:ValueError:不明なURLタイプ

wahlrecht = urllib.parse.quote("http://www.wahlrecht.de/umfragen/") 
page = urllib.request.urlopen(url) 

は、ここで私は取得フルトレースバックです:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/d069049/Documents/BCCN/Predictor/Backend/wahlrecht_polling_firms.py", line 72, in get_tables 
    page = urllib.request.urlopen(wahlrecht) 
    File "/Users/d069049/anaconda/envs/bccn2017/lib/python3.6/urllib/request.py", line 223, in urlopen 
    return opener.open(url, data, timeout) 
    File "/Users/d069049/anaconda/envs/bccn2017/lib/python3.6/urllib/request.py", line 511, in open 
    req = Request(fullurl, data) 
    File "/Users/d069049/anaconda/envs/bccn2017/lib/python3.6/urllib/request.py", line 329, in __init__ 
    self.full_url = url 
    File "/Users/d069049/anaconda/envs/bccn2017/lib/python3.6/urllib/request.py", line 355, in full_url 
    self._parse() 
    File "/Users/d069049/anaconda/envs/bccn2017/lib/python3.6/urllib/request.py", line 384, in _parse 
    raise ValueError("unknown url type: %r" % self.full_url) 
ValueError: unknown url type: 'http%3A//www.wahlrecht.de/umfragen/' 
+1

を動作するはずのhttp%3Aの 次の行は、あなたの問題を作成し

wahlrecht = urllib.parse.quote("http://www.wahlrecht.de/umfragen/") 

を開こうそれを開く前にURLを引用する?もちろん、それは無効になります... –

答えて

1

あなたが解析している:その引数かのように、あなたはそれを引用せずにURLを開く必要があります。 そうでなければあなたは、なぜあなたは...あなたは

wahlrecht = "http://www.wahlrecht.de/umfragen/" 

に変更した場合、それはええと、まあ

関連する問題