2020AV天堂网,午夜色色视频,美女黄片免费观看,欧美黄色电影网站,亚洲人在线

其他新聞

其他新聞

域名建站歷史批量免費查詢工具的簡單介紹

時間:2023-11-10 信途科技其他新聞

前言

由于公司有大量域名信息需要定期查看是否需要續(xù)期,前期都是人工操作比較耗時、耗力。所以衍生了這個小工具。

實現(xiàn)了查詢域名到期時間、并且將近7天內(nèi)到期的域名在Excel中標(biāo)紅,當(dāng)然你也可以添加短信提醒和郵件提醒

代碼步驟1、將域名粘貼到指定txt文件中

比如:domain.txt

2、將指定txt文件中內(nèi)容讀取到list中# 批量讀取文件中的域名def read_file(filePath): with open(filePath, "r") as f: # 打開文件 data = f.readlines() # 讀取文件 return data3、通過某網(wǎng)站獲取域名到期時間# 通過某網(wǎng)站獲取域名到期時間def get_expiry_date(url_list): url_expiry_date_list = [] for url in url_list: url_expiry_date_dict = {} time.sleep(random.randrange(3)) req_whois = urllib.request.urlopen('http://whois.xxxxxx.com/' + url) result = req_whois.read().decode() html = etree.HTML(result) endTimes = html.xpath('//a[@id="update_a2"]/preceding-sibling::span[1]/text()') if len(endTimes) > 0: endTime = endTimes[0].replace('年', '-').replace('月', '-').replace('日', '') else: errorInfo = html.xpath('//div[@class="IcpMain02"]') endTime = errorInfo[0].xpath('string(.)').strip() url_expiry_date_dict['url'] = url.replace('\n', '') url_expiry_date_dict['endTime'] = endTime pprint.pprint(url_expiry_date_dict) url_expiry_date_list.append(url_expiry_date_dict) pprint.pprint(url_expiry_date_list) return url_expiry_date_list4、將結(jié)果寫入Excel文件# 寫入Excel文件def write_excel(domain_list): # 創(chuàng)建一個新的文件 with xlsxwriter.Workbook('host_ip.xlsx') as workbook: # 添加一個工作表 worksheet = workbook.add_worksheet('域名信息') # 設(shè)置一個加粗的格式 bold = workbook.add_format({"bold": True}) # 分別設(shè)置一下 A 和 B 列的寬度 worksheet.set_column('A:A', 50) worksheet.set_column('B:B', 15) # 先把表格的抬頭寫上,并設(shè)置字體加粗 worksheet.write('A1', '域名', bold) worksheet.write('B1', '信息', bold) # 設(shè)置數(shù)據(jù)寫入文件的初始行和列的索引位置 row = 1 col = 0 for domain_ex_date in domain_list: url = domain_ex_date['url'] endTime = domain_ex_date['endTime'] currDate = datetime.today().date() try: endDate = datetime.strptime(endTime, "%Y-%m-%d").date() diffDate = endDate - currDate if diffDate.days <= 7: style = workbook.add_format({'font_color': "red"}) else: style = workbook.add_format({'font_color': "black"}) except: style = workbook.add_format({'font_color': "red"}) pprint.pprint(url + ': ' + endTime) worksheet.write(row, col, url, style) worksheet.write(row, col + 1, endTime, style) row += 15、運行urls = read_file('domain.txt')urls_list = get_expiry_date(urls)write_excel(urls_list)

運行結(jié)果:

6、完整代碼#!/usr/bin/env python# -*- coding: utf-8 -*-# Author:高效碼農(nóng)import pprintimport timeimport randomimport xlsxwriterfrom datetime import datetimeimport urllib.requestfrom lxml import etree# 批量讀取文件中的域名def read_file(filePath): with open(filePath, "r") as f: # 打開文件 data = f.readlines() # 讀取文件 return data# 通過某網(wǎng)站獲取域名到期時間def get_expiry_date(url_list): url_expiry_date_list = [] for url in url_list: url_expiry_date_dict = {} time.sleep(random.randrange(3)) req_whois = urllib.request.urlopen('http://whois.xxxxxx.com/' + url) result = req_whois.read().decode() html = etree.HTML(result) endTimes = html.xpath('//a[@id="update_a2"]/preceding-sibling::span[1]/text()') if len(endTimes) > 0: endTime = endTimes[0].replace('年', '-').replace('月', '-').replace('日', '') else: errorInfo = html.xpath('//div[@class="IcpMain02"]') endTime = errorInfo[0].xpath('string(.)').strip() url_expiry_date_dict['url'] = url.replace('\n', '') url_expiry_date_dict['endTime'] = endTime pprint.pprint(url_expiry_date_dict) url_expiry_date_list.append(url_expiry_date_dict) pprint.pprint(url_expiry_date_list) return url_expiry_date_list# 寫入Excel文件def write_excel(domain_list): # 創(chuàng)建一個新的文件 with xlsxwriter.Workbook('host_ip.xlsx') as workbook: # 添加一個工作表 worksheet = workbook.add_worksheet('域名信息') # 設(shè)置一個加粗的格式 bold = workbook.add_format({"bold": True}) # 分別設(shè)置一下 A 和 B 列的寬度 worksheet.set_column('A:A', 50) worksheet.set_column('B:B', 15) # 先把表格的抬頭寫上,并設(shè)置字體加粗 worksheet.write('A1', '域名', bold) worksheet.write('B1', '信息', bold) # 設(shè)置數(shù)據(jù)寫入文件的初始行和列的索引位置 row = 1 col = 0 for domain_ex_date in domain_list: url = domain_ex_date['url'] endTime = domain_ex_date['endTime'] currDate = datetime.today().date() try: endDate = datetime.strptime(endTime, "%Y-%m-%d").date() diffDate = endDate - currDate if diffDate.days <= 7: style = workbook.add_format({'font_color': "red"}) else: style = workbook.add_format({'font_color': "black"}) except: style = workbook.add_format({'font_color': "red"}) pprint.pprint(url + ': ' + endTime) worksheet.write(row, col, url, style) worksheet.write(row, col + 1, endTime, style) row += 1urls = read_file('domain.txt')urls_list = get_expiry_date(urls)write_excel(urls_list)

掃描二維碼推送至手機(jī)訪問。

版權(quán)聲明:本文由信途科技轉(zhuǎn)載于網(wǎng)絡(luò),如有侵權(quán)聯(lián)系站長刪除。

轉(zhuǎn)載請注明出處http://www.quickersubmitter.com/xintu/8569.html

相關(guān)文章

百度手機(jī)搜索的關(guān)鍵詞排名(手機(jī)app搜索關(guān)鍵詞排名)

大家好,我是古圣,今天給大家?guī)硪惶锥兑羲阉髋琶麅?yōu)化的課程。因為抖音搜索日活已經(jīng)超過了4億多,用戶量非常大,所以今天教大家優(yōu)化抖音搜索的排名。用到的工具:巨量算數(shù)(大家直接百度搜索)進(jìn)入之后點擊頂部的...

「周口360關(guān)鍵詞搜索排名費用」河南省360關(guān)鍵詞排名優(yōu)化

本文目錄一覽: 1、關(guān)鍵詞排名收費方式 快速排名在搜索引擎首頁 2、關(guān)鍵詞優(yōu)化價格多少錢 3、手機(jī)百度網(wǎng)站關(guān)鍵詞快速排名多少錢 4、現(xiàn)在做一個關(guān)鍵詞優(yōu)化排名大概一年要多少錢? 關(guān)鍵詞排名...

建設(shè)商城網(wǎng)站,建設(shè)摩托官方商城怎么樣

建設(shè)摩托官方商城怎么樣不錯。建設(shè)摩托官方商城頁面簡潔,將自己企業(yè)的信息、企業(yè)的介紹、公司的構(gòu)成、公司的愿景都要展示出來,展示了二十幾款摩托車,還設(shè)置一些線上溝通交流的渠道,也有線上購買交易渠道。應(yīng)該說...

提供建站(提供建站模板的公司)

談?wù)劊簽槭裁匆恍┚W(wǎng)站建設(shè)制作公司不提供建站程序源碼?企業(yè)網(wǎng)站源碼是非常重要的,但還是有很多中小企業(yè)沒有意識到這個問題。對企業(yè)來說,網(wǎng)站源碼最好是能夠掌握在自己的手中,這樣我們才能夠有更多的選擇,對今后...

「帝搜抖音關(guān)鍵詞排名優(yōu)化」抖音關(guān)鍵詞排名帝搜軟件

本文目錄一覽: 1、抖音搜索電商怎么做?抖音電商SEO關(guān)鍵詞排名怎么做? 2、抖音關(guān)鍵詞搜索優(yōu)化是什么? 3、抖音關(guān)鍵詞怎么做,抖音視頻優(yōu)化排名怎么做? 4、抖音SEO優(yōu)化需要做些什么?如...

關(guān)鍵詞排名哪家評價好(關(guān)鍵詞排名優(yōu)化哪家好的)

通過百度關(guān)鍵詞排名查詢工具關(guān)鍵詞排名哪家評價好,可以快速得到當(dāng)前網(wǎng)站的關(guān)鍵字在百度收錄的排名情況關(guān)鍵詞排名哪家評價好!便于了解網(wǎng)站自身關(guān)鍵詞排名的優(yōu)勢與劣勢,從而更好地進(jìn)行網(wǎng)站優(yōu)化調(diào)整關(guān)鍵詞排名 狀況...

現(xiàn)在,非常期待與您的又一次邂逅

我們努力讓每一次邂逅總能超越期待

  • 效果付費
    效果付費

    先出效果再付費

  • 極速交付
    極速交付

    響應(yīng)速度快,有效節(jié)省客戶時間

  • 1對1服務(wù)
    1對1服務(wù)

    專屬客服對接咨詢

  • 持續(xù)更新
    持續(xù)更新

    不斷升級維護(hù),更好服務(wù)用戶