blob: 38b09bda2c0bea9fd6256f574188a71c3fabb880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# coding=utf-8
import requests
def get_scode(url):
try:
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
}
# url = 'https://suggestqueries.google.com'
resp = requests.get(url,headers=headers,timeout=5)
print(resp.status_code,url)
print(resp.headers['Content-Type'])
return resp.status_code
except:
print('cuowu',url)
return 'cuowu'
if __name__ == '__main__':
# with open('shifou_web2.txt') as f:
# n=0
# for i in f:
# url='https://'+i.strip()
# scode=get_scode(url)
# n+=1
# print(n)
# if scode==200:
# with open('pao_web_url\keyong2.txt','a') as f:
# f.write(i)
# else:
# with open('bukeyong1.txt','a') as f:
# f.write(i)
# 无用代码,仅作筛选用
# web_set=set()
# with open('pao_web_url\keyong.txt') as f:
# for i in f:
# web_set.add(i.strip())
# print(web_set)
#
# with open('pao_web_url\keyong2.txt') as f:
# for u in f:
# if u.strip() not in web_set:
# with open('pao_web_url\keyong1.txt','a') as f:
# f.write(u)
get_scode('https://www.baidu.com/favicon.ico')
|