Python域名备案查询、短域名查询、域名是否注册查询、直播弹幕发送及查看实时直播弹幕

自从学会使用Python的requests库后,发现越来越多的情况都可以使用python来进行解决,因此寒假期间断断续续的写了这么多的小程序。特此分享出来。

域名备案查询和短域名查询需要在相同文件路径下新建txt文档,将域名保存进去。域名的来源是https://www.cnnic.cn/2/3/55/70/172/index.html,这里可以查询最近要删除的cn域名,全部复制到txt文档既可。

#域名备案查询
#可将结果发送至邮箱
import requests
import json
import time
import smtplib
from email.mime.text import MIMEText
from email.header import Header
import multiprocessing

url = 'https://api.vvhan.com/api/icp?url='

def main():
    count = len(open("domin.txt",'r',encoding='UTF-8').readlines())
    data=[]
    i=1
    n=0
    f = open("domin.txt",encoding='UTF-8')
    line = f.readline()
    while line:
        line = f.readline()
        domin = line[1:-2]
        #print(domin)
        result = requests.get(url + domin).json()
        result_1 = result['success']
        #print(result_1)
        if result_1==True:
            data.append(domin)
            n=n+1
        if n == 5:
            mail(data)
            data=[]
            n=0
        i=i+1
        if i == count:
            mail(data)
        rate(i,count)
    f.close()

def rate(now,num,process):
    mutiply=now/num
    rate = '{:.3%}'.format(mutiply)
    time.sleep(1)
    print("\r",rate, end="")

def mail(url):
    url=str(url)
    smtp = smtplib.SMTP()
    smtp.connect("smtp.qq.com", port=25)
    smtp.login(user="@qq.com", password="")
    message = MIMEText(url, 'plain', 'utf-8')
    message['From'] = Header("域名", 'utf-8') 
    message['To'] = Header('域名', 'utf-8')  
    message['Subject'] = Header('域名', 'utf-8')  
    smtp.sendmail(from_addr="@qq.com", to_addrs="@qq.com", msg=message.as_string())

main()
Python
#短域名查询
import requests
import json

count = len(open("domin.txt",'r').readlines())
f = open("domin.txt")
n=0
data=[]
datadomin=[]
url = 'https://api.vvhan.com/api/icp?url='
while n<=count:
    line = f.readline()
    domin = line[1:-2]
    n=n+1
    if len(domin) <= 6:
        datadomin.append(domin)
        result = requests.get(url + domin).json()
        result_1 = result['success']
        if result_1==True:
            data.append(domin)
            data.append(result['info'])
            
    print('\r',str(n/count*100)+'%',end='')
print('短域名'+str(datadomin))        
print('已备案'+str(data))
a=input()
Python
#直播弹幕发送
#data部分建议在直播间发送一次弹幕,从网络部分查看并且复制过来
import requests

url = 'https://api.live.bilibili.com/msg/send'
data = {
    'bubble': '5',
    'msg': '这才八点呀~~~~',
    'color': '14893055',
    'mode': '4',
    'fontsize': '25',
    'rnd': '1672927581',
    'roomid': '23141761',
    'csrf': '41deb48737dd1e2e59bd4c2954690a4d',
    'csrf_token': '41deb48737dd1e2e59bd4c2954690a4d',
}

headers = {
    'cookie': "",
    'origin': 'https://live.bilibili.com',
    'referer': 'https://live.bilibili.com/blanc/1029?liteVersion=true',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
}
response = requests.post(url=url, data=data, headers=headers)
print(response.status_code)
Python
#直播弹幕获取
import json
import urllib
import requests

r =23141761
z={}
xiaoxi = []
ren = []
postxiaoxi=set()
postren=set()

while True:
js = requests.get("http://api.live.bilibili.com/ajax/msg?roomid=23141761").json()
j = js["data"]["room"] # 获取json中data中的room中的内容
jz=json.dumps(js["data"]["room"])
for content in range(len(j)):
nickname = j[content]["nickname"]
text = j[content]["text"]
#print(nickname,text,content)
#[j[content]["text"]] = j[content]["nickname"] # 内容为key,字典的key不能重复
if j[content]['text'] not in postxiaoxi: # 如果set中没有这个值(set特性是不能重复)#在这做判断 如果有新的消息 在这新建对象 不会重复
xiaoxi.append(j[content]) # 消息数组将这个不重复的值存进
postxiaoxi.add(j[content]['text']) # set存进这个不重复的值,为了后面判断是否重复做准备
print(j[content]['text'])
Python
分享一下
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇
本站总访问量 次|(ノ´▽`)ノ♪|本站总访客数
萌ICP备20247001号
Theme Argon
隐藏
变装