Python Brush voting script implementation code _python

Source: Internet
Author: User

The

principle is to use proxy IP to access the polling address. With a lot of threads, it's fast.
last night two hours on the brush more than 1000 votes, mainly proxy IP is not easy to find.

running

in 2.7 environments

#!/usr/bin/env python #-*-coding:utf-8-*-import urllib2 from threading import Thread to time import time C 
        Lass Vote (Thread): Def __init__ (self, proxy): thread.__init__ (self) self.proxy = Proxy Self.url = ' http://www.studentboss.com/zhuanti/2014/cncc/vote.php?id=19 ' self.timeout = ten def run (self ): Proxy_handle = Urllib2. Proxyhandler ({"http": R ' http://%s '% self.proxy}) opener = Urllib2.build_opener (proxy_handle) urllib2.in Stall_opener (opener) Try:req = Urllib2.urlopen (Self.url, timeout=self.timeout) result 
                = Req.read (). Decode (' GBK ') print result pos = result.find (U ' success ') if POS > 1: Addnum () Else:pass except Exception,e:print e.message, ' 
Error ' Def addnum (): Global n + + 1 def shownum (): return n = 0 threads = [] 
proxylist = open (' Proxy.txt ', ' r ') for proxy in proxylist:t = Vote (proxy) threads.append (t) if __name __ = = ' __main__ ': start_time = time () to I in Threads:i.start () to I in Threads:i.joi  N () print '%s votes have been voted successfully using%s seconds '% (Shownum (), Time ()-start_time)
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.