python - 使用 python 点击​​ http url 获取 IOError

标签 python jira-rest-api

我尝试按如下方式进行操作

import urllib
second_query="http://example.com"
pw = urllib.urlopen(second_query)
pw = pw.read()
print pw

我正在尝试点击 jira api - http://example.com但我收到以下错误

Traceback (most recent call last):
      File "abc.py", line 7, in <module>
        pw = urllib.urlopen(second_query)
      File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 87, in urlopen
        return opener.open(url)
      File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 203, in open
        return getattr(self, name)(url)
      File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 358, in open_http
        return self.http_error(url, fp, errcode, errmsg, headers)
      File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 371, in http_error
        result = method(url, fp, errcode, errmsg, headers)
      File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 683, in http_error_401
        errcode, errmsg, headers)
      File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 381, in http_error_default
        raise IOError, ('http error', errcode, errmsg, headers)
    IOError: ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x138e26c8>)

请提出解决方案。

最佳答案

通过阅读错误,可以清楚地看出您没有所需的授权:

IOError: ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x138e26c8>

您必须以某种方式提供必要的凭据...但是我很确定 Jira 提供了高级 API 来使用其工具,因此您不必使用低级方法。

关于python - 使用 python 点击​​ http url 获取 IOError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27503110/

相关文章:

python - 更改列时出现稀疏效率警告

java - 在 groovy 中使用 HTML 格式的 JIRA Rest API 创建发行说明

java - Jira OAuth - 无法创建应用程序链接

Python 作为 Windows 看门狗

python - wxpython 没有 'adv'

python - 如何在Python中请求主域名(而不是参数)上包含非unicode字符的url?

python - 生成和发送 MS Outlook 任务

jira - 使用 Jira 的 Python API,如何为问题设置史诗链接?

java - JiraRestClient 搜索未返回 JQL 查询的结果

java - 如何使用 Java 检查 JIRA 列表中是否存在自定义字段值