吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1706|回复: 6
收起左侧

[求助] python抓包精易论坛实现自动签到问题

[复制链接]
tsu.xxw 发表于 2022-3-15 16:35
最近想研究下用python自动做任务,想到先拿精易论坛练练手,目标是自动实现精易论坛随机帖子评分
用fillder抓取到的评分post包截图如下
精易论坛1.jpg
用python的request,与xpath能够获取到每个页面的formash,pid,tid,剩余的post参数不变,需要注意的是referer中也有tid,pid,目前这些都做好了,对目标url发起请求,得到的响应却如下
精易论坛2.jpg
求教大神们,请问这怎么解决呢?

我写的签到代码如下
[Python] 纯文本查看 复制代码
def dailyTask():
    headers = {
        'cookie': '这个不让看',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'
    }
    # for i in range(5):
    session = requests.session()
    pageNumber = random.randint(34, 2000)
    # url = 'https://bbs.125.la/thread-1472' + str(pageNumber) + '-1-1.html'
    url_page = 'https://bbs.125.la/thread-14720892-1-1.html'      #先换成指定url,好分析
    rep = session.get(url=url_page, headers=headers)
    if rep.status_code==200:
        print('进入帖子详情页成功')
        tree=etree.HTML(rep.text)
        a_list=tree.xpath('//*[@id="ak_rate"]/@onclick')
        addr=a_list[0]
        str1=addr.split(',')
        str2=str1[1].split('&')
        tid1=str2[2]
        pid1=str2[3]
        tid2=tid1.split('=')[1]
        pid2=pid1.split('=')[1]
        pid3=pid2.split('\'')[0]
        tid = tid2
        pid = pid3            #获取到tid与pid
        formash1=tree.xpath('//*[@id="vfastpost"]/input/@value')
        formash=formash1[0]   #获取到formash
        print("获取pid={}与tid={}与formash={}成功,开始自动评分".format(pid,tid,formash))
        #开始评分
        url_score='https://bbs.125.la/forum.php?mod=misc&action=rate&ratesubmit=yes&infloat=yes&inajax=1'

        data='formhash='+formash+'&tid='+tid+'&pid='+pid+'&referer=https%3A%2F%2Fbbs.125.la%2Fforum.php%3Fmod%3Dviewthread%26tid%3D'+tid+'%26page%3D0%23pid'+pid+'&handlekey=rate&score4=%2B1&reason=%E6%84%9F%E8%B0%A2%E5%88%86%E4%BA%AB%EF%BC%8C%E5%BE%88%E7%BB%99%E5%8A%9B%EF%BC%81%7E'
        rep_score=session.post(url=url_score,data=data.encode())
        print(rep_score.status_code)
        print(rep_score.text)


    else:
        print('进入帖子失败')





免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
xuyh + 1 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Rezalt 发表于 2022-3-15 16:41
两种方式:
1、把headers放到session.post里面去
2、用session.headers.update() 方法更新session的headers
 楼主| tsu.xxw 发表于 2022-3-15 16:48
Rezalt 发表于 2022-3-15 16:41
两种方式:
1、把headers放到session.post里面去
2、用session.headers.update() 方法更新session的heade ...

无效老哥
精易论坛3.jpg
Prozacs 发表于 2022-3-15 17:52
import requests
import random
from lxml import etree
def dailyTask():
    headers = {
        'cookie': 'lDlk_ecc9_connect_is_bind=0; lDlk_ecc9_nofavfid=1; lDlk_ecc9_smile=4D1; Hm_lvt_c6927066ad2f2806b262f20b26fabff4=1640921266; lDlk_ecc9_saltkey=ZWyWb9p8; lDlk_ecc9_lastvisit=1644818076; lDlk_ecc9_auth=09a60ywzuiQo%2B1bF4JUFkfhAdVLbD5hzyL3M2ZCgmz2JhO5Cpp%2FuCe20rY9p; lDlk_ecc9_atarget=1; lDlk_ecc9_sid=iWT7w8; lDlk_ecc9_lip=101.32.214.114%2C1646989793; lDlk_ecc9_ulastactivity=7344E4ZvFN3iGqXzwmOk%2BwAdCFeJRQAnRvqYaTJ5Cl8Aeq2ZzrCj; lDlk_ecc9_sendmail=1; Hm_lvt_fa32dadde3745af309b587b38d20ea1d=1646185732,1646723534,1646979913,1647337430; lDlk_ecc9_onlineusernum=5715; lDlk_ecc9_st_p=648717%7C1647337535%7C84fa46ad70830397ac960da5f5fc4638; lDlk_ecc9_visitedfid=98D121D81D16D51D27D99D96D147D161; lDlk_ecc9_viewid=tid_14720892; Hm_lpvt_fa32dadde3745af309b587b38d20ea1d=1647337537; lDlk_ecc9_lastcheckfeed=648717%7C1647337535; lDlk_ecc9_lastact=1647337577%09forum.php%09misc',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'
    }
    # for i in range(5):
    session = requests.session()
    pageNumber = random.randint(34, 2000)
    # url = 'https://bbs.125.la/thread-1472' + str(pageNumber) + '-1-1.html'
    url_page = 'https://bbs.125.la/thread-14720892-1-1.html'  # 先换成指定url,好分析
    rep = session.get(url=url_page, headers=headers)
    if rep.status_code == 200:
        print('进入帖子详情页成功')
        tree = etree.HTML(rep.text)
        a_list = tree.xpath('//*[@id="ak_rate"]/@onclick')
        addr = a_list[0]
        str1 = addr.split(',')
        str2 = str1[1].split('&')
        tid1 = str2[2]
        pid1 = str2[3]
        tid2 = tid1.split('=')[1]
        pid2 = pid1.split('=')[1]
        pid3 = pid2.split('\'')[0]
        tid = tid2
        pid = pid3  # 获取到tid与pid
        formash1 = tree.xpath('//*[@id="vfastpost"]/input/@value')
        formash = formash1[0]  # 获取到formash
        print("获取pid={}与tid={}与formash={}成功,开始自动评分".format(pid, tid, formash))
        # 开始评分
        url_score = 'https://bbs.125.la/forum.php?mod=misc&action=rate&ratesubmit=yes&infloat=yes&inajax=1'
        data = 'formhash=' + formash + '&tid=' + tid + '&pid=' + pid + '&referer=https%3A%2F%2Fbbs.125.la%2Fforum.php%3Fmod%3Dviewthread%26tid%3D' + tid + '%26page%3D0%23pid' + pid + '&handlekey=rate&score4=%2B1&reason=%E6%84%9F%E8%B0%A2%E5%88%86%E4%BA%AB%EF%BC%8C%E5%BE%88%E7%BB%99%E5%8A%9B%EF%BC%81%7E'
        headers['Content-Type'] = 'application/x-www-form-urlencoded'
        headers['Referer'] = 'https://bbs.125.la/thread-14720892-1-1.html'
        rep_score = session.post(url=url_score, data=data,headers=headers)
        print(rep_score.status_code)
        print(rep_score.text)


    else:
        print('进入帖子失败')


if __name__ == '__main__':
    dailyTask()

Content-Type 以及 Referer 问题

免费评分

参与人数 2吾爱币 +2 热心值 +1 收起 理由
whichway + 1 谢谢,也解决了我的问题
tsu.xxw + 1 + 1 谢谢@Thanks!

查看全部评分

 楼主| tsu.xxw 发表于 2022-3-15 18:28
Prozacs 发表于 2022-3-15 17:52
import requests
import random
from lxml import etree

谢谢,学到了
不苦小和尚 发表于 2022-3-15 19:03
一看就是id不对啊
pzx521521 发表于 2022-3-16 11:06
4L 正解
这种一般都是漏东西了
解决方法是
抓一个 网站的包
抓一个 自己post的包
对比一下就知道哪里不一样了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-29 08:15

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表