자기가 쓴 약간의 복지 코드(二)
1638 단어 복리
저자: vpoet 주: 이 시리즈는 코드만 붙이고 코드는 주석하지 않습니다.흥미 있는 사람은 스스로 읽어 보면 알겠지만, 순전히 오락이므로, 관리자가 손을 들어 전재가 있으면 반드시 출처를 밝히지 않기를 바랍니다
#coding=utf-8
import webbrowser
import time
import urllib2
import re
import os
import thread
import threading
mylock = threading.RLock()
tabcount=1
def BlogFun(n,url,MaxVisitor,threadnumber):
visitcount = r'<span class="link_view" title=" ">(\d+) </span>'
global tabcount
while True:
mylock.acquire()
if tabcount >10:
os.system('taskkill /F /IM chrome.exe')
tabcount = 1
else:
tabcount = tabcount + 1
mylock.release()
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)
time.sleep(n)
if int(Ref[0])>MaxVisitor:
break
if __name__=="__main__":
main_url = "http://blog.csdn.net/u013018721/article/details/37996979"
threadSum= 5
MaxVisitor = 1050
timedelay=3
print main_url+" ... "+"
"
for threadnumber in range(threadSum):
thread.start_new_thread(BlogFun,(timedelay,main_url,MaxVisitor,threadnumber,))
threadnumber=threadnumber+1
print "Main Thread Over.............."
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
자기가 쓴 약간의 복지 코드(二)자기가 쓴 약간의 복지 코드(二) 저자: vpoet 주: 이 시리즈는 코드만 붙이고 코드는 주석하지 않습니다.흥미 있는 사람은 스스로 읽어 보면 알겠지만, 순전히 오락이므로, 관리자가 손을 들어 전재가 있으면 반드시...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.