zoukankan      html  css  js  c++  java
  • [python 学习笔记] 简单刷投票功能

    最近好久没写了,其实有道云里积累了好多,但是没时间整理。

    实在是太多事情要做了

    好多投票都是不需要登录的,这种刷起来很简单。 原理就是 X-Forwarded-For 。废话不多说上代码

    import requests
    import time
    
    host = 'xx'
    def getSession():
    	ss = requests.session()
    	ss.headers['Host']= host
    	ss.headers['Connection']=r'keep-alive'
    	ss.headers['Accept']=r'*/*'
    	ss.headers['Origin']=r'http://zhengwen.hecul.com'
    	ss.headers['X-Requested-With']=r'XMLHttpRequest'
    	ss.headers['User-Agent']=r'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36'
    	ss.headers['Content-Type']=r'application/x-www-form-urlencoded; charset=UTF-8'
    	ss.headers['Referer']=host
    	ss.headers['Accept-Encoding']=r'gzip, deflate'
    	ss.headers['Accept-Language']=r'zh-CN,zh;q=0.8,en;q=0.6,en-GB;q=0.4'
    	return ss
    
    for x in range(3,150):
    	try:
    		time.sleep(3)
    		ss = getSession()
    		# 模拟同一wifi不同设备。
    		ss.headers["X-Forwarded-For"] = '192.168.0.'+ str(x)
    		# 获取cookie
    		ss.get(host)
    
    		# 设置数据长度。可以由下边 data 获取
    		data='id=2&voteoption=101'
    		ss.headers['Content-Length'] = str(len(data))
    
    		# 发送数据
    		r = ss.post(r'%s/plug/vote/'%host,data=data)
    		print(r.text)
    	except Exception as e:
    		print(str(e))
    		pass
    
  • 相关阅读:
    java设计模式笔记(1)-适配器模式
    linux下源码编译安装mysql
    spring boot入门
    2016年终总结
    CentOS获取公网IP
    shell中的$0 $n $# $* $@ $? $$
    shell中各种括号的作用详解()、(())、[]、[[]]、{}
    10个实战及面试常用Linux Shell脚本编写
    记录centos下nl与cat -n的不同
    grep、cut、awk、sed的使用
  • 原文地址:https://www.cnblogs.com/boliu/p/8137048.html
Copyright © 2011-2022 走看看