Python 3.x 在urllib中使用代理时遇到问题
我正在尝试使用代理,以便能够访问外部数据。我的代理似乎不起作用。我正在使用Python 3和urllib 我已经尝试将proxies=proxies提供给urlopen。我尝试过使用ProxyHandlerPython 3.x 在urllib中使用代理时遇到问题,python-3.x,proxy,urllib,Python 3.x,Proxy,Urllib,我正在尝试使用代理,以便能够访问外部数据。我的代理似乎不起作用。我正在使用Python 3和urllib 我已经尝试将proxies=proxies提供给urlopen。我尝试过使用ProxyHandler #Importing dataframe and request stuff import pandas as pd import json import urllib from urllib.request import urlopen from urllib.request import
#Importing dataframe and request stuff
import pandas as pd
import json
import urllib
from urllib.request import urlopen
from urllib.request import ProxyHandler
#mapping proxy dictionary
proxies = {
'ftp': 'ftp://x:80',
'http': 'http://x:80',
'https': 'https://x:80'
}
#handling the proxy
proxy_support = urllib.request.ProxyHandler(proxies)
下面的代码可能与此无关,但我不知道
#Identifying the file
json_file = "https://gis.fema.gov/arcgis/rest/services/NSS/OpenShelters/MapServer/0/query?where=1%3D1&outFields=*&returnGeometry=false&outSR=4326&f=json"
#reading the file
data = urlopen(json_file).read()
#loading data
raw_json = json.loads(data)
#formatting data
formatted_json = [feature['attributes'] for feature in raw_json['features']]
#creating data frame
df = pd.DataFrame(formatted_json)
我一直在超时,因为我的代理不起作用,不确定我到底做错了什么