Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python urllib2.HTTPError:HTTP错误500:内部服务器错误_Python_Http_Sockets_Urllib2_Irc - Fatal编程技术网

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

Python urllib2.HTTPError:HTTP错误500:内部服务器错误,python,http,sockets,urllib2,irc,Python,Http,Sockets,Urllib2,Irc,这个小脚本在漏洞数据库中搜索已知的漏洞,但是当我试图在IRC中使用它时,这个脚本似乎不起作用,但是当我单独运行它时,它就可以了 我所说的“单独”是指: if data.find('!exploits') != -1: nick = data.split('!')[ 0 ].replace(':','') results = api.exploitdb.search(arg) sck.send('PRIVMSG ' + chan + " :" + ' Result

这个小脚本在漏洞数据库中搜索已知的漏洞,但是当我试图在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')) 
这个很好用,但我想和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'])
回溯(最近一次呼叫最后一次):
文件“C:\Users\Rabia\Documents\scripts\client.py”,第232行,在
结果=api.exploitdb.search(arg)
文件“C:\Python26\lib\site packages\shodan\api.py”,第63行,在搜索中
返回self.parent.\u请求('exploitdb/search',dict(q=query,**kwargs))
文件“C:\Python26\lib\site packages\shodan\api.py”,第116行,在请求中
data=urlopen(self.base_url+function+'?'+urlencode(params)).read()
文件“C:\Python26\lib\urllib2.py”,第126行,在urlopen中
return\u opener.open(url、数据、超时)
文件“C:\Python26\lib\urllib2.py”,第397行,打开
响应=方法(请求,响应)
文件“C:\Python26\lib\urllib2.py”,第510行,在http\u响应中
“http”、请求、响应、代码、消息、hdrs)
文件“C:\Python26\lib\urllib2.py”第435行出错
返回自我。调用链(*args)
文件“C:\Python26\lib\urllib2.py”,第369行,在调用链中
结果=func(*args)
文件“C:\Python26\lib\urllib2.py”,第518行,默认为http\u error\u
raise HTTPError(请求获取完整url(),代码,消息,hdrs,fp)
urllib2.HTTPError:HTTP错误500:内部服务器错误

您的代码应该正常

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


您可以检查其含义。

意外情况是什么意思?我应该检查哪些条件?因为我在一个类似的代码中遇到了同样的错误。你能告诉我哪里出了问题吗?谢谢@何杰
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