This commit is contained in:
2025-08-05 09:19:34 +08:00
commit 584548d006
1696 changed files with 53855 additions and 0 deletions
@@ -0,0 +1,29 @@
import requests
import time
#爬取100次网页所需时间
def get_HTML_Text():
i = 0
while i < 100:
try:
r = requests.get(url)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.status_code
except:
print("出现异常")
i += 1
if __name__ == "__main__":
time1 = time.time()
url = "http://www.baidu.com"
u = 0 # 记录爬取异常次数
for i in range(100 + u):
if get_HTML_Text() == 200:
u = u
else:
u += 1
time2 =time.time()
print(f"爬取100次所需要的时间为{time2-time1}")