自己写的一点福利代码(一)

来源:互联网 发布:淘宝网招聘 编辑:程序博客网 时间:2024/04/27 06:22
自己写的一点福利代码(一)


作者:vpoet
注:这个系列我只贴代码,代码不注释.有兴趣的自己读读就懂了,纯属娱乐,望管理员抬手
     若有转载一定不要注明来源


#coding=utf-8import webbrowserimport timeimport urllib2import reimport osimport threadtabcount=1def BlogFun(n,url,MaxVisitor):    visitcount = r'<span class="link_view" title="阅读次数">(\d+)人阅读</span>'    global tabcount     while True:        if tabcount >10:            os.system('taskkill /F /IM chrome.exe')            tabcount = 1        else:            tabcount = tabcount + 1        webbrowser.open(url,new=1)        request=urllib2.Request(url)        request.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6')        opener = urllib2.build_opener()        fblog = opener.open(request)        htm = fblog.read()        Ref=re.findall(visitcount,htm);        print url+": "+str(int(Ref[0]))+"人阅读"        if int(Ref[0])>MaxVisitor:            break        time.sleep(n)if __name__=="__main__":        Domain="http://blog.csdn.net"    Blog_url = "http://blog.csdn.net/u013018721/article/details/37996979"    FreshSecond = 3    MaxVisitor = 1000    BlogFun(FreshSecond,Blog_url,MaxVisitor)    


1 0
原创粉丝点击