Bing Maps API 拒绝我在办公室互联网环境中的连接
我可以在公司笔记本电脑上断开VPN后,可以在家里运行代码并将其连接到Bing Map API,但是在我在家工作时,我必须连接我的公司WiFi,我无法连接到Bing地图API。如何解决这个问题? 错误消息 代码
coordinate_url=[]
for index,row in df.iterrows():
url="http://dev.virtualearth.net/REST/v1/Locations?CountryRegion=" + str(row["Country Code"]) +"&adminDistrict="+str(row["State"])+"&postalCode=" + str(row['Postcode']) + "&locality=" + str(row['City']) + "&maxResults=1&key=" + Api_key
r = requests.get(url)
results = json.loads(r.content)
coordinate_url.append(results)
我已经解决了问题,实际上很容易,下面是我的代码。我从本文中获取代码。 。实际上,当我向HTTP发送请求以刮擦内容时,我只需要表示公司的Proxy_port和Proxy_host。然后,我可以在公司的互联网环境中使用bing Map API
import requests
url = "http://httpbin.org/ip"
proxy_host = "proxy.crawlera.com"
proxy_port = "8010"
proxy_auth = ":"
proxies = {
"https": "https://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port),
"http": "http://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port)
}
r = requests.get(url, proxies=proxies, verify=False)
I can run my code and connect to Bing Map API normally in my home after disconnect vpn on my company laptop when I work from home, but after I come to office, I have to connect my company WIFI and I can't connect to Bing Map API. how to solve the issue ?
the error message
The code
coordinate_url=[]
for index,row in df.iterrows():
url="http://dev.virtualearth.net/REST/v1/Locations?CountryRegion=" + str(row["Country Code"]) +"&adminDistrict="+str(row["State"])+"&postalCode=" + str(row['Postcode']) + "&locality=" + str(row['City']) + "&maxResults=1&key=" + Api_key
r = requests.get(url)
results = json.loads(r.content)
coordinate_url.append(results)
i have solve the problem ,actually it will easy, below is my code. i get the code from this paper. https://www.zyte.com/blog/python-requests-proxy/ . Actually I only need indicate the proxy_port and proxy_host of my company when I send a request to http to scrape content. Then I can use Bing Map API in my company Internet environment
import requests
url = "http://httpbin.org/ip"
proxy_host = "proxy.crawlera.com"
proxy_port = "8010"
proxy_auth = ":"
proxies = {
"https": "https://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port),
"http": "http://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port)
}
r = requests.get(url, proxies=proxies, verify=False)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很可能是您公司的防火墙的问题。去与您的IT团队交谈,然后获取
dev.virtualearth.net
添加到允许列表中。This is most likely an issue with your company’s firewall. Go talk to your IT team and get
dev.virtualearth.net
added to the allow list.