2015-06-19 53 views
-1
enUrl='res.iweshow.com' 
sr = requests.get(enUrl) 
print(sr) 

當我將使用python的請求模塊的HTTP請求,這裏是回溯:如何在python中沒有方案的情況下發送http請求?

raise InvalidSchema("No connection adapters were found for '%s'" % url)requests.exceptions.InvalidSchema: No connection adapters were found for 
+1

你爲什麼不能在前面加上'HTTP:在你的URL //'? – metatoaster

+0

@metatoaster有時你可能不會沒有,如果它是一個http或https – The6thSense

+1

那麼你如何期待你使用的庫知道? – metatoaster

回答

0

如果你的目的是使用HTTP,如問題指出,那麼答案是簡單的「加HTTP方案「中。

使用urlparse可以輕鬆檢查該方案是否缺少url。

在代理的情況下,默認的方案是現在HTTP see herehere

相關問題