master
panqihua 4 years ago
parent 7aa2428b98
commit 03c88ce5da
  1. 205
      .gitignore
  2. 2
      README.md
  3. 32
      config/config.py
  4. 21
      config/log.py
  5. 2
      domain/.gitignore
  6. 61
      domain/alyundomain.py
  7. 25
      domain/checkDomain.py
  8. 41
      huawei/Test.py
  9. 14
      requirement.txt

205
.gitignore vendored

@ -0,0 +1,205 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea
*.iml

@ -0,0 +1,2 @@
* [域名检索](domain)
* [华为云安全组白名单配置](huawei)

@ -0,0 +1,32 @@
import configparser
import logging
from logging.handlers import TimedRotatingFileHandler
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(BASE_DIR)
cf = configparser.ConfigParser()
config_path=BASE_DIR+"/config.ini"
if not os.path.exists(config_path):
raise Exception("配置文件:%s不存在" % config_path)
cf.read(config_path,encoding='utf-8')
logFile = cf.get('file', 'logFile')
logger=logging.getLogger()
logger.setLevel(logging.INFO)
def init():
log_format=logging.Formatter(fmt="%(asctime)s %(levelname)s : %(message)s",datefmt='%Y-%m-%d %H:%M:%S')
# 在控制台打印日志
streamHandler = logging.StreamHandler()
streamHandler.setFormatter(log_format)
logger.addHandler(streamHandler)
logpath=BASE_DIR+"/log/"
print(logpath)
if not os.path.exists(BASE_DIR+"/log/"):
os.mkdir(logpath)
timedRotatingFileHandler=TimedRotatingFileHandler(filename=logpath+"all.log",when='H',interval=1,encoding='utf-8')
timedRotatingFileHandler.setFormatter(log_format)
logger.addHandler(timedRotatingFileHandler)

@ -0,0 +1,21 @@
import time
from config.config import init
from config.config import logger
start = int(time.time())
init()
def getRunTimeInt():
return (int(time.time()) - start)
def getRunTime():
return '程序已经执行%d' % (int(time.time()) - start)
def writeInfo(msg):
logger.info('%s\t(%s)' % (msg, getRunTime()))
def writeError(msg):
logger.error('%s\t(%s)' % (msg, getRunTime()))

2
domain/.gitignore vendored

@ -0,0 +1,2 @@
# Created by .ignore support plugin (hsz.mobi)
chromedriver.exe

@ -0,0 +1,61 @@
import time
import math
import requests
import json
from bs4 import BeautifulSoup
# Create a new instance of the Firefox driver
from selenium.webdriver.chrome import webdriver
driver = webdriver.WebDriver(
executable_path="D:\JetBrains\PycharmProjects\python_requirements_summary\chromedriver.exe")
start_url = 'https://mi.aliyun.com/?spm=5176.8070854.az_625vhq.1.22242c4fIPqBfQ'
def getReq(domain):
try:
return requests.post('http://icp.chinaz.com/hklt.net', {"type": "host", "s": domain, "guid": "%24guid"},
timeout=10)
except:
time.sleep(3)
return getReq(domain)
driver.get(start_url)
token = driver.execute_script('return window.umToken')
driver.quit()
pageSize = 50
current_page = 1
last_page = None
while last_page is None or current_page <= last_page:
session = requests.Session()
url = 'https://domainapi.aliyun.com/onsale/search?fetchSearchTotal=true&token={0}&currentPage={1}&pageSize={2}&productType=2&minPrice=0&maxPrice=50&searchIntro=false&keywordAsPrefix=false&keywordAsSuffix=false&exKeywordAsPrefix=false&exKeywordAsSuffix=false&exKeywordAsPrefix2=false&exKeywordAsSuffix2=false'.format(token, current_page, pageSize)
res = session.get(url, headers={
'Referer': 'https://mi.aliyun.com/?spm=5176.8070854.az_625vhq.1.22242c4fIPqBfQ',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36',
'Sec-Fetch-Mode': 'no-cors'
})
res_json = json.loads(res.content)
if 'data' in res_json:
if last_page is None and 'searchTotal' in res_json['data']:
last_page = min(100,math.ceil(res_json['data']['searchTotal'] / pageSize))
if 'pageResult' in res_json['data'] and 'data' in res_json['data']['pageResult']:
for data in res_json['data']['pageResult']['data']:
domain = data['domainName']
price = data['price']
res = getReq(domain)
if res.status_code == 200:
res_html = BeautifulSoup(res.content, 'html.parser')
if res_html.select_one("p[class='tc col-red fz18 YaHei pb20']") is None:
print('{0}已备案,价格{1}'.format(domain, price))
else:
print('{0}未备案'.format(domain))
else:
print('{0}备案信息获取失败'.format(domain))
else:
print(res_json)
current_page = current_page + 1

@ -0,0 +1,25 @@
#域名注册检测
import jsons as jsons
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36',
'Referer': 'https://domain.oray.com/suffix/xyz.html'
}
if __name__ == '__main__':
i = 1
while True:
domain='%d.xyz' % i
response = requests.get('https://mcheck.oray.com/domain/check?domain[]=%s&record=1' % domain, headers=headers)
if response.status_code == 200:
content = response.content.decode(response.apparent_encoding)
if content.startswith('{') and content.endswith('}'):
content = jsons.loads(content)
if domain in content and 'avail' in content[domain] and content[domain]['avail']==1:
print('域名:%s未注册' % domain)
else:
print('域名:%s已注册' % domain)
else:
print('error')
i = i + 1

@ -0,0 +1,41 @@
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
import json
from openstack import connection
from config.log import writeInfo
from config.config import cf
conn = connection.Connection(
auth_url=cf.get('huaweicloud', 'auth_url'),
user_domain_id=cf.get('huaweicloud', 'userDomainId'),
project_id=cf.get('huaweicloud', 'projectId'),
username=cf.get('huaweicloud', 'username'),
password=cf.get('huaweicloud', 'password')
)
if __name__ == '__main__':
security_group_id = cf.get('huaweicloud', 'security_group_id')
remote_ip_prefix=cf.get('huaweicloud', 'remote_ip_prefix')
writeInfo("放通IP:%s" % remote_ip_prefix)
rules = conn.vpcv1.security_group_rules(security_group_id=security_group_id)
for rule in rules:
if rule.description!='允许安全组内的弹性云服务器彼此通信':
conn.vpcv1.delete_security_group_rule(rule.id)
conn.vpcv1.create_security_group_rule(security_group_id=rule.security_group_id, direction=rule.direction,
description=rule.description, remote_ip_prefix=remote_ip_prefix,
port_range_max=rule.port_range_max, port_range_min=rule.port_range_min,protocol=rule.protocol)
writeInfo(rule)
writeInfo("成功刷新白名单")

@ -0,0 +1,14 @@
certifi==2019.11.28
chardet==3.0.4
deprecation==2.0.7
huaweicloud-sdk-python==1.0.21
idna==2.8
iso8601==0.1.12
keystoneauth1==3.4.0
packaging==20.1
pbr==5.4.4
pyparsing==2.4.6
requests==2.22.0
six==1.14.0
stevedore==1.32.0
urllib3==1.25.8
Loading…
Cancel
Save