获取代理服务器错误'未找到名称或服务'使用PythonAnywhere服务器时

时间:2018-04-06 11:06:35

标签: python python-3.x flask python-requests pythonanywhere

我正在使用Python3 / flask。当我尝试访问网址时,它会显示“未找到名称或服务”。但是当我尝试使用我的本地编辑器Pycharm时,我能够访问该URL。我知道PythonAnywhere只允许列入白名单的URL,否则会出现403禁止错误。在我的情况下,我得到的服务没有找到'错误因此不是PythonAnywhere限制访问的情况。我的代码如下(由于安全问题,无法共享凭据)

                line = 1

                try:
                    USERNAME = "******"
                    PASSWORD = "******"

                    URI = "https://jofa9908cdf9.hana.ondemand.com/ibass/IBASS_1/IOT_DASHBOARD/SERVICES/IOT_DASHBOARD.xsjs?CMD=equip_dev_health&IP_PLANT=1000&IP_PLANT=1"

                    USER_AGENT = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"

                    proxies = {"http": "http://<username>:<password>@rb-proxy-apac.bosch.com:8080","https": "https://<username>:<password>@rb-proxy-apac.bosch.com:8080"}


                    CERT_FILE = False

                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.HTTPError)

                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.ConnectionError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.PoolError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.ProxySchemeUnknown)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.HTTPWarning)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.MaxRetryError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.ProxyError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.SecurityWarning)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.SSLError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.NewConnectionError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.ClosedPoolError)
                    requests.packages.urllib3.disable_warnings(urllib3.exceptions.RequestError)


                    line += 1#2

                    authed_session = requests.Session()

                    line += 1#3

                    authed_session.auth = (USERNAME, PASSWORD)

                    line += 1#4
                    authed_session.verify = CERT_FILE
                    authed_session.trust_env = CERT_FILE

                    line += 1#5

                    authed_session.headers.update({'User-Agent':USER_AGENT})

                    line += 1#6
                    fetched_data = authed_session.get(URI, proxies=proxies)

                    line += 1#7

                    line += 1#8
                    #print(fetched_data.text)
                    data = fetched_data.json()
                    return jsonify(str(data['EQUIP_ON']))

                    #soup = bs4.BeautifulSoup(fetched_data.text,'lxml')
                    #x = soup.select('content')
                    #x = soup.select('div')
                    #print(x)

                    #for i in x:
                    #   print(i.getText())
                    #  #print(i)

                except Exception as e:
                    #print(line)
                    #print(str(e))
                    return jsonify("at line number="+str(line)+" "+str(e))

我在第6行遇到异常。例外情况如下 - (我有一个前端。这里的图片是我前端的截图)

enter image description here

0 个答案:

没有答案