from urllib.request import urlopen
from time import time
t1=time()
url = ""
title = ""
for i in range (0,1):
for j in range(1):
try:
#url="http://192.168."+"%s"%i+"."+"%s"%j+"/"
url="http://192.168.119.211/JudgeOnline"
socket =urlopen("%s" % url)
content = socket.read()
title=content
re_words = re.compile(u"[\u4e00-\u9fa5]+")
title=re_words.search(title,0)
print(url +" : " +title)
except :
pass
fa=open("log.txt","a")
fa.close()
finally:
fb=open("result.txt","a")
fb.write("%s :" % url)
if len(title) <= 0:
fb.write("No content -----Rick Note.")
fb.write("%s\n" % title)
fb.close()
t2=time()
print("Time cost :"+str(t2-t1))
爬虫抓取网页
最新推荐文章于 2023-10-27 09:30:00 发布