【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

admin 2022年12月3日16:31:07评论101 views字数 14119阅读47分3秒阅读模式

[huayang]

github:https://github.com/light-Life/Selenium-yiban

自动 发布投票

# !/usr/bin/python
# -*- coding:utf-8 -*-
# name: Qsj377
# time: 2020.11.9
import requests,base64,random,time,threading
def renzheng(cookie):
    renzheng_r = requests.get(url='http://www.yiban.cn/user/info/index?type=2',headers={
        'Connection': 'keep-alive',
        'Cache-Control': 'max-age=0',
        'DNT': '1',
        'Upgrade-Insecure-Requests': '1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,ru;q=0.5,zh-TW;q=0.4,da;q=0.3,ht;q=0.2,tr;q=0.1',
        'Cookie': cookie
    })
def yiban_check_ma(cookie):#请求验证码
    yiban_check_ma_headers = {"Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-CN,zh;q=0.9", "Connection": "close","Content-Type": "application/x-www-form-urlencoded; charset=UTF-8","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ""(KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",'Cookie': cookie}
    yiban_check_ma_url = "https://www.yiban.cn/captcha/index?Tue%20Dec%2004%202018%2000:01:26%20GMT+0800%20(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)"
    try:
        yiban_check_ma_r = requests.get(yiban_check_ma_url,headers=yiban_check_ma_headers,timeout=3)
    except Exception:
        yiban_check_ma_r = requests.get(yiban_check_ma_url, headers=yiban_check_ma_headers, timeout=None)
    image_data = base64.b64encode(yiban_check_ma_r.content).decode().replace("\r", "")
    baidu_api(image_data,cookie)
def baidu_api(image_data,cookie):#需要传入字符串:image_data
    baidu_api_headers = {'Content-Type':'application/x-www-form-urlencoded'}#必选参数
    baidu_api_data = {'image':image_data.encode("utf8")} #base64编码的图片,已去头
    try:
        baidu_api_r = requests.post(url='https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.f3f0f5de06299de7a2a22a4c29dbc0b9.2592000.1608696091.282335-22957927',headers=baidu_api_headers, data=baidu_api_data,timeout=3)
    except Exception:
        baidu_api_r = requests.post(url='https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.f3f0f5de06299de7a2a22a4c29dbc0b9.2592000.1608696091.282335-22957927',headers=baidu_api_headers, data=baidu_api_data, timeout=None)
    if('words_result' in baidu_api_r.json() and len(baidu_api_r.json()['words_result'])>=1):
        yzm = baidu_api_r.json()['words_result'][0]['words']
        toupiao(cookie,yzm)
    else:
        yiban_check_ma(cookie)
def toupiao(cookie,yzm):
    shiju = ['一寸光阴一寸金,寸金难买寸光阴。', '明日复明日,明日何其多,我生待明日,万事成蹉跎。', '天行健,君子以自强不息。', '少壮不努力,老大徒悲伤。', '三更灯火五更鸡,正是男儿读书时。','黑发不知勤学早,白首方悔读书迟。', '宝剑锋从磨砺出,梅花香自苦寒来。']
    x = shiju[random.randint(0, 6)]
    toupiao_headers = {
        'Accept': 'application/json, text/javascript, */*; q=0.01',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,ru;q=0.5,zh-TW;q=0.4,da;q=0.3,ht;q=0.2,tr;q=0.1',
        'Connection': 'keep-alive',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Cookie': cookie,
        'DNT': '1',
        'Host': 'www.yiban.cn',
        'Origin': 'http://www.yiban.cn',
        'Referer': 'http://www.yiban.cn/my/publishvote',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51',
        'X-Requested-With': 'XMLHttpRequest'
    }
    toupiao_data = {'puid': '12792328', 'scope_ids': '1000680', 'title': x, 'subjectTxt': '','subjectPic': '', 'options_num': '2', 'scopeMin': '1', 'scopeMax': '1', 'minimum': '1','voteValue': '2021-06-17 21:55', 'voteKey': '2', 'public_type': '0', 'isAnonymous': '1','voteIsCaptcha': '0', 'istop': '1', 'sysnotice': '2', 'isshare': '1', 'rsa': '1','dom': '.js-submit', 'group_id': '1000680', 'subjectTxt_1': shiju[random.randint(0, 6)],'subjectTxt_2': shiju[random.randint(0, 6)], 'captcha': yzm}
    #改三个参数puid#忘了、scope_ids#忘了、group_id#学院id
    try:
        toupiao_r = requests.post(url='https://www.yiban.cn/vote/vote/add', headers=toupiao_headers, data=toupiao_data,timeout=3)
    except Exception:
        toupiao_r = requests.post(url='https://www.yiban.cn/vote/vote/add', headers=toupiao_headers,data=toupiao_data, timeout=None)
    print(toupiao_r.json())
    if('444' in toupiao_r.text):
        renzheng(cookie)
        toupiao(cookie,yzm)
    elif ('200' in toupiao_r.text):
        print(toupiao_r.json()['message'],x)
    else:
        yiban_check_ma(cookie)
#print(requests.get('https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=***_secret=***').json()['access_token'])
cookie = '***'+str(int(round(time.time(),3)*1000))#在这里填写cookie
for i in range(0,10000):
    yiban_check_ma(cookie)

配置

因为涉及到图片识别这里调用的是百度的api

所以要先去百度智能云注册一个账号https://cloud.baidu.com/?from=console

完成后

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本
【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

然后创建应用

最后参照百度api调用守则https://cloud.baidu.com/doc/OCR/s/Ck3h7y2ia

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

自动点赞 投票 评论

# !/usr/bin/python
# -*- coding:utf-8 -*-
# name: huayang
# time: 2020.11.11
import re
import time
import requests
import threading
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
url = '***'#总投票界面
def First(x,y,cookie,cookie2,name):
    browser = webdriver.Chrome()
    for x in range(int(x),int(y)):#页
        urls = url + str(x)
        headers = {
            'Connection': 'close', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'DNT': '1',
            'X-Requested-With': 'XMLHttpRequest',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Origin': 'https://www.yiban.cn',
            'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Dest': 'empty',
            'Referer': 'https://www.yiban.cn/my/publishvote', 'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,ru;q=0.5,zh-TW;q=0.4,da;q=0.3,ht;q=0.2,tr;q=0.1',
            'Cookie': cookie
        }
        try:
            response = requests.get(urls,headers=headers)
        except Exception:
            response = requests.get(urls, headers=headers)
        span = re.findall('.*?<span class="tx">(.*?)</sp.*?',response.text,re.S)
        href = re.findall('.*?target="_blank" href="(.*?)"',str(span))
        for i in href:
            i = 'https://www.yiban.cn' + i
            browser.get(i)
            browser.add_cookie({'name': 'yiban_user_token', 'value': cookie2})
            time.sleep(0.5)
            browser.refresh()
            time.sleep(0.5)
            source = browser.page_source
            if '取消赞' in source:
                print('已点赞')
            else:
                location = browser.find_element_by_id('btn_like')#必须使用id才能定位鼠标悬停
                ActionChains(browser).move_to_element(location).perform()#鼠标悬停
                time.sleep(0.1)
                browser.find_element_by_id('btn_like').click()  # 点赞
                time.sleep(0.5)
            if 'id="vote_result" style=' in source:
                print('已投票')
            else:
                browser.find_element_by_class_name('btn_chs').click()  # 选择
                time.sleep(0.4)
                browser.find_element_by_class_name('btn_vote').click()  # 投票按钮
            if name in source:
                print('已评论')
            else:
                speech = browser.find_element_by_xpath('//input[@type="text"]')
                speech.send_keys('大家好,我是马保国')#评论
                time.sleep(0.3)
                try:
                    browser.find_element_by_class_name('submit').click()  # 发送评论
                except:
                    browser.find_element_by_class_name('submit').click()  # 发送评论
                time.sleep(0.5)
    print('循环结束')
cookie = [
    'name','cookie!',
    '**','***!',
    '**','***!',
    '**','***!',
    '**','***!',
    '**','***!'
]#第一个是真实姓名,二是此cookie值
if __name__ == '__main__':
    threads = []    #创建线程数组
    number = 1 #cookie
    number2 = 0#cookie2
    number3 = 0#name
    for i in range(6):#设置线程数,cookie要记得随之更改
        cookie2 = re.findall('.*?yiban_user_token=(.*?)!.*?', str(cookie), re.S)#cookie最后加上!在不影响cookie的同时能使正则匹配成功
        threads.append(threading.Thread(target=First, args=(111,120,cookie[number],cookie2[number2],cookie[number3])))#页数改前两位
        number +=2
        number2 +=1
        number3 +=2
    for t in threads:
            t.start()   #启动线程
    for t in threads:
            t.join()    #守护线程
'''
本代码优势:
1.可以刷共建指数
2.完全模拟真人点击防封率大大提升
3.采用多线程刷分效率大大提高
4.代码简洁有注释
'''

第三方以及插件配置

因为我的是mac这里就以mac进行讲解

安装第三方库requestsselenium

pip3 install requests -i https://mirrors.aliyun.com/pypi/simple/
pip3 install selenium -i https://mirrors.aliyun.com/pypi/simple/

进pycharm进行确认

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

win同样

首先你得有chrome

然后去下载chromedriver

https://npm.taobao.org/mirrors/chromedriver

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

这里有很多版本目前最新的chrome下载这个即可

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

mac

上点开访达然后command+shift+g

搜索/usr/local/bin 把下载好的文件拖进去就行了

然后运行这段代码看是否能正常调用

from selenium import webdriver
browser = webdriver.Chrome()

如果正常调用并且没有报错则可以开搞

如果能调用但是出现秒退的情况则可能是chromedriver版本问题

win配置:https://blog.csdn.net/hijacklei/article/details/107876474

url为投票界面

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

设置完成后就可以冲冲了

问题

运行久后会出现如下错误实属正常,基本是网络原因

【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本

再次运行即可

运行久后可能会封ip或者服务器抽风

等一会儿就行了

都玩这个相信都有一定基础的了,别的问题应该都能自行解决

注:此为老版本的演示视频,新版本的懒得搞

大体差不多,增加了多线程和错误

演示视频

这里那个是刷新而不是跳了一个

看代码逻辑

警告:此代码可招致封ip,5~15分钟即可解封

写在最后

代码不算难但也修修改改了n次,也凝聚了长达半个月的心血

本代码不接受任何提问,但可以提出不同的思路

祝玩得愉快,也可以拿去赚点小钱

说起来我们也赚了差不多三四十了哈哈

2021.3.12更

点赞投票

import requests
from lxml import etree
import time
import threading
def First(cookie):
    for i in range(2208, 3456):
        url = 'http://www.yiban.cn/Newgroup/showMorePub/group_id/***/puid/***/type/3/page/' + str(i)
        headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9','Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Cache-Control': 'max-age=0', 'Connection': 'close', 'Cookie': cookie, 'DNT': '1', 'Host': 'www.yiban.cn','Upgrade-Insecure-Requests': '1','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.81'}
        r = requests.get(url=url, headers=headers)
        link = etree.HTML(r.content).xpath('/html/body/main/div/div/div/div[1]/section[2]/ul//li/div/div[1]/span[1]/a/@href')
        for j in range(0, len(link)):
            link[j] = 'https://www.yiban.cn' + link[j]
            # 点赞
            vote_id = link[j][50:59]
            DianZan_datas = {'puid': '12792328', 'group_id': '1000680', 'vote_id': vote_id, 'actor_id': '32628138','flag': '1'}
            DianZan_r = requests.post(url='https://www.yiban.cn/vote/vote/editLove', headers=headers,data=DianZan_datas)
            # 点赞调试代码
            if DianZan_r.json()['message'] == '操作成功':
                pass
            # print('点赞成功')
            else:
                pass
            # print(DianZan_r.json())
            time.sleep(0.1)
            # 投票
            TouTiao_data = {'puid': '***', 'group_id': '***', 'vote_id': vote_id, 'actor_id': '32628138','voptions_id': '441568499', 'minimum': '1', 'scopeMax': '1'}
            TouTiao_r = requests.post(url='https://www.yiban.cn/vote/vote/act', headers=headers, data=TouTiao_data)
            # 投票调试代码
            if TouTiao_r.json()['message'] == '操作成功':
                pass
            # print('投票成功')
            else:
                pass
            # print(TouTiao_r.json())
            time.sleep(0.2)
        print(i, '页', etree.HTML(requests.get(url=url, headers=headers).content).xpath('/html/body/main/div/div/div/div[1]/section[1]/div[2]/div/span[1]/text()'))
cookie = (
    '***'
)
threads = []
for i in cookie:
    threads.append(threading.Thread(target=First, args=(i, )))
for t in threads:
    t.start()
    time.sleep(0.2)
for t in threads:
    t.join()

发票点赞投票

import base64
import random
import requests
import threading
import time
def yiban_check_ma(cookie):#请求验证码
    yiban_check_ma_headers = {"Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-CN,zh;q=0.9", "Connection": "close","Content-Type": "application/x-www-form-urlencoded; charset=UTF-8","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ""(KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",'Cookie': cookie}
    yiban_check_ma_url = "https://www.yiban.cn/captcha/index?Mon Dec 14 2020 18:45:34 GMT 0800 (中国标准时间)="
    try:
        yiban_check_ma_r = requests.get(yiban_check_ma_url,headers=yiban_check_ma_headers,timeout=None)
    except Exception:
        yiban_check_ma_r = requests.get(yiban_check_ma_url, headers=yiban_check_ma_headers,timeout=None)
    image_data = base64.b64encode(yiban_check_ma_r.content).decode().replace("\r", "")
    baidu_api_headers = {'Content-Type':'application/x-www-form-urlencoded'}#必选参数
    baidu_api_data = {'image':image_data.encode("utf8")} #base64编码的图片,已去头
    try:
        baidu_api_r = requests.post(url='https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.cae65f3935c6094515f0fa9b948e28c4.2592000.1617352274.282335-22957927',headers=baidu_api_headers, data=baidu_api_data,timeout=None)
    except Exception:
        baidu_api_r = requests.post(url='https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.cae65f3935c6094515f0fa9b948e28c4.2592000.1617352274.282335-22957927',headers=baidu_api_headers, data=baidu_api_data,timeout=None)
    if 'words_result' in baidu_api_r.json() and len(baidu_api_r.json()['words_result']) >= 1 and len(baidu_api_r.json()['words_result'][0]['words']) == 1:
        yzm = baidu_api_r.json()['words_result'][0]['words']
        toupiao(cookie,yzm)
    else:
        yiban_check_ma(cookie)
def toupiao(cookie,yzm):
    shiju = ['一寸光阴一寸金,寸金难买寸光阴。', '明日复明日,明日何其多,我生待明日,万事成蹉跎。', '天行健,君子以自强不息。', '少壮不努力,老大徒悲伤。', '三更灯火五更鸡,正是男儿读书时。','黑发不知勤学早,白首方悔读书迟。', '宝剑锋从磨砺出,梅花香自苦寒来。']
    x = shiju[random.randint(0, 6)]
    toupiao_headers = {'Accept': 'application/json, text/javascript, */*; q=0.01','Accept-Encoding': 'gzip, deflate','Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,ru;q=0.5,zh-TW;q=0.4,da;q=0.3,ht;q=0.2,tr;q=0.1','Connection': 'keep-alive','Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8','Cookie': cookie,'DNT': '1','Host': 'www.yiban.cn','Origin': 'http://www.yiban.cn','Referer': 'http://www.yiban.cn/my/publishvote','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51','X-Requested-With': 'XMLHttpRequest'}
    toupiao_data = {'puid': '***', 'scope_ids': '***', 'title': x, 'subjectTxt': '','subjectPic': '', 'options_num': '2', 'scopeMin': '1', 'scopeMax': '1', 'minimum': '1','voteValue': '2023-09-31 23:59', 'voteKey': '2', 'public_type': '0', 'isAnonymous': '1','voteIsCaptcha': '0', 'istop': '1', 'sysnotice': '2', 'isshare': '1', 'rsa': '1','dom': '.js-submit', 'group_id': '1000680', 'subjectTxt_1': shiju[random.randint(0, 6)],'subjectTxt_2': shiju[random.randint(0, 6)], 'captcha': yzm}
    #改三个参数puid、scope_ids、group_id#学院id
    toupiao_r = requests.post(url='https://www.yiban.cn/vote/vote/add', headers=toupiao_headers, data=toupiao_data,timeout=None)
    if '200' in toupiao_r.text:
        print(toupiao_r.status_code,toupiao_r.json()['message'])
        #点赞
        print('投票ID:',toupiao_r.json()['data']['lastInsetId'])
        vote_id = toupiao_r.json()['data']['lastInsetId']
        DianZan_datas = {
            'puid': '***',
            'group_id': '***',
            'vote_id': vote_id,
            'actor_id': '***',
            'flag': '1'
        }
        DianZan_r = requests.post(url='https://www.yiban.cn/vote/vote/editLove',headers=toupiao_headers,data=DianZan_datas)
        # 点赞调试代码
        if DianZan_r.json()['message'] == '操作成功':
            print('点赞成功')
        else:
            print(DianZan_r.json())
        #投票
        TouTiao_data = {
            'puid':'***',
            'group_id':'***',
            'vote_id':vote_id,
            'actor_id':'***',
            'voptions_id':'***',
            'minimum':'1',
            'scopeMax':'1'
        }
        TouTiao_r = requests.post(url='https://www.yiban.cn/vote/vote/act',headers=toupiao_headers,data=TouTiao_data)
        #投票调试代码
        if TouTiao_r.json()['message']=='操作成功':
            print('投票成功')
        else:
            print(TouTiao_r.json())
    else:
        print(toupiao_r.status_code,toupiao_r.json())
        yiban_check_ma(cookie)
cookie = '***'
for i in range(0,100):
    yiban_check_ma(cookie)
    time.sleep(60)

[/huayang]

FROM:浅浅淡淡[hellohy]

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年12月3日16:31:07
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【原创 脚本】易班自动发布投票 ,自动点赞、 投票、 评论脚本http://cn-sec.com/archives/1443167.html

发表评论

匿名网友 填写信息