Python----Rage Brush Click Volume PYQT5 Edition

Source: Internet
Author: User
Tags emit

Function

Enter the blogger user name to increase the number of blogger clicks


Software


Part of the source

# coding=utf-8__author__ = ' a359680405 ' from PyQt5 import qtwidgetsfrom pyqt5.qtcore import qthreadfrom pyqt5.qtcore impor T Pyqtsignalfrom visitspage. Ui. MainForm Import Ui_mainformfrom visitspage.    Ui.newform import ui_newformimport re,timeimport urllib.requestfrom bs4 import beautifulsoupclass WorkThread (QThread): _strname= "a359680405" _brushnum=50 trigger=pyqtsignal (str) #传参 def __init__ (Self,strnam E,brushnum): Super (Workthread,self). __init__ () Self._strname=strname Self._brushnum=brushnum def R Un (self): p=re.compile ('/' +self._strname+ '/article/details/... ') #自己的博客主页 url = "HTTP://BLOG.CSD n.net/"+self._strname #使用build_opener () is intended to allow the Python program to mimic the browser for access opener = Urllib.request.build_opener () o        Pener.addheaders = [(' User-agent ', ' mozilla/5.0 ')] try:html = Opener.open (URL). read (). Decode (' Utf-8 ') Except Urllib.error.HTTPError: #print (' URLLIB.ERror.  Httperror ') self.trigger.emit (' No this user ') Time.sleep (1) #出现错误, stop a few seconds first allfinds = P.findall (HTML) #print (allfinds) self.trigger.emit (str (allfinds)) URLBase = "Http://blog.csdn.net" #需            To merge a portion of the URL #页面中的网址有重复的, you need to use set to repeat mypages = List (set (allfinds)) for I in Range (len (mypages)): Mypages[i] = urlbase+mypages[i] #print (' the page to be brushed has: ') self.trigger.emit (' the page to be brushed has: ') for index, page In Enumerate (mypages): # print (str (index), page) Self.trigger.emit (str (index) + page) #所有的页面都            Brush #print (' Start brush below ' oh: ') self.trigger.emit (' Start brush below: ') for index, page in Enumerate (mypages): For j in Range (Self._brushnum): try:pagecontent = Opener.open (page). Read (). Decode                      (' utf-8 ') #使用BeautifulSoup解析每篇博客的标题 soup = BeautifulSoup (pagecontent) BlogtitlE = str (soup.title.string) Blogtitle = Blogtitle[0:blogtitle.find ('-')] #print (s TR (j), Blogtitle) Self.trigger.emit (str (j) + "" + blogtitle) except Urllib.error.HTTPE Rror as E: #print (' Urllib.error.HTTPError ') self.trigger.emit (' Urllib.error.HTTP Error ') time.sleep (1) #出现错误, stop a few seconds first except Urllib.error.URLError: # Print (' Urllib.error.URLError ') self.trigger.emit (' Urllib.error.URLError ') time.s Leep (1) #出现错误, stop Time.sleep (0.1) for a few seconds before the server denies access to class Vpform (Qtwidgets.qmainwindow,ui_mainform): Def __        Init__ (self): Super (Vpform,self). __init__ () self.setupui (self) self._worker=[] self._form=[] Self.submitBt.clicked.connect (Self.shua) #索引增加 def Shua (self): Thread=workthread (Self.nameLe.text () , int (Self.numLe.text ()))            Form=newform () thread.trigger.connect (Form.display) form.show () Thread.Start (    ) self._worker.append (thread) self._form.append (Form) class NewForm (Qtwidgets.qwidget,ui_newform): def __init__ (self): Super (Newform,self). __init__ () Self.setupui (self) def display (self,m): SELF.D Isplaytb.append (m) if __name__== "__main__": Import sys app=qtwidgets.qapplication (SYS.ARGV) myshow=vpform () Mys How.show () Sys.exit (App.exec_ ())



Source Address http://download.csdn.net/detail/a359680405/9046865

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Python----Rage Brush Click Volume PYQT5 Edition

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.