import requests
import re
import json
ses = requests.Session()
first_url = "htt [防检测] p://112.74.185.30:8080/yiban-web/stu/toSubject.jh [防检测] tml?courseId=8"
first_headers={
'host': '1 12.74.185.30:8080',
'Accept-Encoding': 'gzip, deflate',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1',
'Referer': 'h [防检测] ttp://112.74.185.30:8080/yiban-web/stu/toCourse.jht [防检测] ml',
'DNT': '1',
'Connection': 'keep-alive',
}
first_cookies = {'JSESSIONID': 'E3857AA04B846ED5414BA5EE0421617F'}
res=ses.get(url=first_url,cookies=first_cookies)
text=res.text
answer = re.findall(r'"answer":\"(.*?)\"',text)
uuid = re.findall(r'baseInfoData.data.uuid = \'(.*)\'', text)
headers = {
'host': '112.74.185.30:8080',
'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate',
'Content-Type': 'application/json; charset=UTF-8',
'Origin': 'ht [防检测] tp://112.74.185.30:8080',
'Content-Length': '57',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1',
'Referer': 'h [防检测] ttp://112.74.185.30:8080/yiban-web/stu/toSubject.jht [防检测] ml?cour [防检测] seId=8',
'DNT': '1',
'Connection': 'keep-alive',
'Cookie': 'JSESSIONID=0D7E4E12942F878489DEA60B97561F8F',
}
data={
'answer':'A',
'courseId':'8',
'uuid':''
}
data['uuid'] = uuid[0]
data['answer']=answer[0]
res =
ses.post(url='ht [防检测] tp://112.74.1 [防检测] 85.30:8080/yiban-web/stu/changeSituation.jht [防检测] ml',
headers=headers, data=json.dumps(data))
print(res.text)
===========================================
利用 session(),使上次 get 和下次 post 成功对同一个页面请求了,但是第二次的 post 从被验证为非法访问变成了响应头 500.....(应该是 UUID 对上了所以验证为合法访问了,但是不知道什么原因出现 500 错误) 看了下,第一次 GET 到的页面中提交函数是用 muj.ajax (我不太懂 js。。),
function changeSituation(answer){
var data={'answer':answer,'courseId':baseInfoData.data.subject.courseId,'uuid':baseInfoData.data.uuid};
mui.ajax({
url: '/yiban-web/stu/changeSituation.jhtml',
async: true,
cache: false,
type: 'post',
data:data,
dataType: 'json',
…………………………
=============================================
不知道现在有什么解决办法呢,望请教!