加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

批量查询网址是否备案

发布时间:2020-12-17 17:24:02 所属栏目:Python 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #coding:utf-8import requests,xlrd,datetime,threading,sysfrom bs4 import BeautifulSoupreload(sys)sys.setdefaultencoding("utf-8")def beian(url

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

#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)

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读