python3 requests IP代理池出錯
阿新 • • 發佈:2018-12-11
Traceback (most recent call last): File "E:/py1803/pachong/mimimovie/movies_spider.py", line 129, in <module> m.get_content() File "E:/py1803/pachong/mimimovie/movies_spider.py", line 65, in get_content for item in urlList: File "E:/py1803/pachong/mimimovie/movies_spider.py", line 43, in movies_info response = requests.get(url, proxies=proxy, headers=headers) File "D:\Python3.6\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "D:\Python3.6\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "D:\Python3.6\lib\site-packages\requests\sessions.py", line 499, in request prep.url, proxies, stream, verify, cert File "D:\Python3.6\lib\site-packages\requests\sessions.py", line 671, in merge_environment_settings no_proxy = proxies.get('no_proxy') if proxies is not None else None AttributeError: 'list' object has no attribute 'get'
原因:
IP代理的變數的變數賦值錯誤,ip每次訪問只能使用一個,而不是一個列表
解決方案:
查詢ip代理池的值是否賦值正確,每次從列表隨機提取出一個ip去訪問網站