urllib2.HTTPError:HTTP错误500:内部服务器错误

时间:2011-04-12 08:25:24

标签: python http sockets urllib2 irc

  if data.find('!exploits') != -1:
     nick = data.split('!')[ 0 ].replace(':','')
     results = api.exploitdb.search(arg)
     sck.send('PRIVMSG ' + chan + " :" + ' Results found: %s' % results['total'] + '\r\n')
     for exploit in results['matches'][:5]:
              sck.send('PRIVMSG ' + chan + "" + '%s:' % (exploit['description'] + '\r\n')) 

这个小脚本在exploit-db中搜索已知漏洞,但是当我尝试在IRC中使用它时,脚本似乎不起作用,但是当我单独运行它时它很好,

单凭我的意思就是:

from shodan import WebAPI

SHODAN_API_KEY = "MY API KEY"
api = WebAPI(SHODAN_API_KEY)

results = api.exploitdb.search('PHP')

print 'Results found: %s' % results['total']
for exploit in results['matches'][:5]:
        print '%s:' % (exploit['description'])

一个工作完美,但我想用它与IRC

但是我收到了这个错误:

Traceback (most recent call last):
  File "C:\Users\Rabia\Documents\scripts\client.py", line 232, in <module>
    results = api.exploitdb.search(arg)
  File "C:\Python26\lib\site-packages\shodan\api.py", line 63, in search
    return self.parent._request('exploitdb/search', dict(q=query, **kwargs))
  File "C:\Python26\lib\site-packages\shodan\api.py", line 116, in _request
    data = urlopen(self.base_url + function + '?' + urlencode(params)).read()
  File "C:\Python26\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python26\lib\urllib2.py", line 397, in open
    response = meth(req, response)
  File "C:\Python26\lib\urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python26\lib\urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "C:\Python26\lib\urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "C:\Python26\lib\urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error

1 个答案:

答案 0 :(得分:1)

你的代码应该没问题。

这应该是服务器问题。 内部错误 - 由于意外情况,服务器无法满足请求

您可以查看return status的含义。