标签:webkit htm cep mac os x exce safari code lin mac os
#!/usr/bin/env python
# coding=utf-8
import requests
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"}
with open(‘/Users/fin4nc/Desktop/123.txt‘, ‘r‘) as f:
for line in f:
line = line.strip(‘\n‘).strip(‘\ufeff‘)
url = ‘http://‘ + line
print(url)
try:
response= requests.get(url, headers=headers, timeout=5).status_code
print(response)
if response== 200:
print(‘可打开‘)
else:
print(response)
except Exception as e:
with open(‘/Users/fin4nc/Desktop/1.txt‘, ‘a+‘) as f1:
error = f1.write(line+‘\n‘)
print(e)
标签:webkit htm cep mac os x exce safari code lin mac os
原文地址:http://www.cnblogs.com/b1ancheng/p/7671181.html