Bing Maps API 拒绝我在办公室互联网环境中的连接

发布于 2025-01-21 02:45:14 字数 1320 浏览 2 评论 0原文

我可以在公司笔记本电脑上断开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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自找没趣 2025-01-28 02:45:14

这很可能是您公司的防火墙的问题。去与您的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文