1
게시물 요청을 통해 인증을위한 간단한 코드가 있습니다. 서버는 모든 요청은 "javax.faces.ViewState"javax.faces.ViewState 같은 변수 를 생성하는 = 123456784356754파이썬 및 함수 인수
import requests
import re
global_headers = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0',
'Accept': 'application/xml, text/xml, */*; q=0.01',
'Referer': 'http://serrver.com/login/'}
req = requests.Session(headers=global_headers)
def javalue_parser():
javalue = re.findall(r'name="javax.faces.ViewState" id="javax.faces.ViewState" value="(.*?)"')
print javalue[0]
return javalue
my_post_req = req.post('http://server.com/login/',
data={'phone': '+11(123)456-78-91',
'loginForm': 'loginForm',
'javax.faces.ViewState': "%s" % javalue_parser()
})
난 항상 오류가
Traceback (most recent call last):
File "rework_sms.py", line 28, in <module>
'javax.faces.ViewState': "%s" % javalue_parser()
File "test.py", line 19, in javalue_parser
javalue = re.findall(r'name="javax.faces.ViewState" id="javax.faces.ViewState" value="(.*?)"')
TypeError: findall() takes at least 2 arguments (1 given)
인수가 무엇을 필요한가?
* * * *를 사용하여 regex *를 사용하여 찾으시겠습니까? 그것은 다른 주장입니다. – kennytm
12344556과 같은 일부 숫자이지만 게시 요청에서 함수를 실행할 수 없습니다. javalue_parser (my_post_req.content)를 사용하면 잘 작동합니다 – Alexander