微信域名检测

臭大佬 2021-11-11 17:37:58 1639
Python 
简介 可以检测域名是否被腾讯拦截

代码

win 版

"""
# coding:utf-8
"""
from selenium import webdriver
from bs4 import BeautifulSoup
import re
import time

chaeck_url = "www.baidu.com"

# 引入 selenium  和实例化一个浏览器引擎
driver = webdriver.Chrome(
    executable_path=r"E:/Program Files (x86)/chromedriver_win32/chromedriver.exe"
)

driver.get("https://urlsec.qq.com/complain.html")
# 定位搜索框
inputs = driver.find_element_by_id("url")
# 在搜索框中输入文本
inputs.send_keys(chaeck_url)
# 定位提交查询
search = driver.find_element_by_id("check-url")
# 点击提交查询
search.click()
# 等待 3 秒
time.sleep(3)
wbdata = driver.page_source
soup = BeautifulSoup(wbdata, "lxml")
node = soup.findAll(name="div", attrs={"class": "about-cert"})
soup_str = str(node)
# about-cert 加了 display: none; 表明已经被封了,
pattern = r'class="about-cert" style="display: none;"'
m = re.search(pattern, soup_str)
if m is not None:
    print("通过")
else:
    print("被封了")

linux 版

"""
# coding:utf-8
"""
from selenium import webdriver
from bs4 import BeautifulSoup
import re
import time

chaeck_url = "www.baidu.com"

# 引入 selenium  和实例化一个浏览器引擎
ch_options = webdriver.ChromeOptions()
# 为Chrome配置无头模式
ch_options.add_argument("--headless")  
ch_options.add_argument('--no-sandbox')
ch_options.add_argument('--disable-gpu')
ch_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=ch_options)

driver.get("https://urlsec.qq.com/complain.html")
# 定位搜索框
inputs = driver.find_element_by_id("url")
# 在搜索框中输入文本
inputs.send_keys(chaeck_url)
# 定位提交查询
search = driver.find_element_by_id("check-url")
# 点击提交查询
search.click()
# 等待 3 秒
time.sleep(3)
wbdata = driver.page_source
soup = BeautifulSoup(wbdata, "lxml")
node = soup.findAll(name="div", attrs={"class": "about-cert"})
soup_str = str(node)
# about-cert 加了 display: none; 表明已经被封了,
pattern = r'class="about-cert" style="display: none;"'
m = re.search(pattern, soup_str)
if m is not None:
    print("通过")
else:
    print("被封了")