python模拟浏览器抓包_Python 模拟浏览器请求,怎么保持前一个 get 和后一个 post 是对同一个页面进行处理呢?...

13

2018-05-16 13:53:26 +08:00

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',

…………………………

=============================================

不知道现在有什么解决办法呢,望请教!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值