批量查询网址是否备案
发布时间:2020-05-24 23:49:17 所属栏目:Python 来源:互联网
导读:批量查询网址是否备案
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 #coding:utf-8
import requests,xlrd,datetime,threading,sys
from bs4 import BeautifulSoup
reload(sys)
sys.setdefaultencoding("utf-8")
def beian(url,excel):
f = xlrd.open_workbook(excel)
sheet1 = f.sheet_by_name('Sheet1')
num_cols = sheet1.ncols
for curr_col in range(num_cols):
rows = sheet1.col_values(curr_col)
for each in rows:
data = {'s': each,'guid': '1e4b4b3f-310f-4aaa-90f7-a552db48758d'}
r = requests.post(url,data=data)
soup = BeautifulSoup(r.content,'html.parser')
tags = soup.find_all('div',id='contenthtml')
try:
for tag in tags:
d_name = tag.find('td',class_='tdright').get_text()
#print d_name
print ('%s 已备案') % each
except AttributeError:
print ('%s 未备案') % each
if __name__ == "__main__":
url = 'http://tool.chinaz.com/beian.aspx'
excel = (r'C:1.xlsx')
threads = []
print "程序开始运行%s" % datetime.datetime.now()
t1 = threading.Thread(target=beian,args=(url,excel))
threads.append(t1)
for th in threads:
th.setDaemon(True)
th.start()
th.join()
print "程序结束时间%s" % datetime.datetime.now()
#beian(url,excel)
以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
