Compare commits
No commits in common. "9b7ef6e752ee51897e356e85956b76dceb10df6b" and "fce0ff43bbbf953c3e8a5bfca7b403018e6777d8" have entirely different histories.
9b7ef6e752
...
fce0ff43bb
|
|
@ -0,0 +1,8 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="29">
|
||||
<item index="0" class="java.lang.String" itemvalue="protobuf" />
|
||||
<item index="1" class="java.lang.String" itemvalue="pytweening" />
|
||||
<item index="2" class="java.lang.String" itemvalue="trio-websocket" />
|
||||
<item index="3" class="java.lang.String" itemvalue="PyMsgBox" />
|
||||
<item index="4" class="java.lang.String" itemvalue="setuptools" />
|
||||
<item index="5" class="java.lang.String" itemvalue="numpy" />
|
||||
<item index="6" class="java.lang.String" itemvalue="pycparser" />
|
||||
<item index="7" class="java.lang.String" itemvalue="requests" />
|
||||
<item index="8" class="java.lang.String" itemvalue="sniffio" />
|
||||
<item index="9" class="java.lang.String" itemvalue="onnxruntime" />
|
||||
<item index="10" class="java.lang.String" itemvalue="trio" />
|
||||
<item index="11" class="java.lang.String" itemvalue="selenium" />
|
||||
<item index="12" class="java.lang.String" itemvalue="pyreadline3" />
|
||||
<item index="13" class="java.lang.String" itemvalue="soupsieve" />
|
||||
<item index="14" class="java.lang.String" itemvalue="ddddocr" />
|
||||
<item index="15" class="java.lang.String" itemvalue="urllib3" />
|
||||
<item index="16" class="java.lang.String" itemvalue="sympy" />
|
||||
<item index="17" class="java.lang.String" itemvalue="PyScreeze" />
|
||||
<item index="18" class="java.lang.String" itemvalue="PyAutoGUI" />
|
||||
<item index="19" class="java.lang.String" itemvalue="wincertstore" />
|
||||
<item index="20" class="java.lang.String" itemvalue="pyperclip" />
|
||||
<item index="21" class="java.lang.String" itemvalue="wheel" />
|
||||
<item index="22" class="java.lang.String" itemvalue="you-get" />
|
||||
<item index="23" class="java.lang.String" itemvalue="wsproto" />
|
||||
<item index="24" class="java.lang.String" itemvalue="sortedcontainers" />
|
||||
<item index="25" class="java.lang.String" itemvalue="PySocks" />
|
||||
<item index="26" class="java.lang.String" itemvalue="PyGetWindow" />
|
||||
<item index="27" class="java.lang.String" itemvalue="PyRect" />
|
||||
<item index="28" class="java.lang.String" itemvalue="Pillow" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.12" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.9 (learn_demo)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/learn_demo.iml" filepath="$PROJECT_DIR$/.idea/learn_demo.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : input函数.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/19 15:36
|
||||
@Software : PyCharm
|
||||
"""
|
||||
# input() 函数用于接收用户输入的数据,返回值为字符串类型。
|
||||
|
||||
name = input('请输入姓名:')
|
||||
age = input('请输入年龄:')
|
||||
print(f'姓名:{name},年龄:{age}')
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : 列表.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/26 17:06
|
||||
@Software : PyCharm
|
||||
"""
|
||||
|
||||
# 创建列表的两种方式
|
||||
# 1.使用[]创建
|
||||
list1 = [1,2,3,4,5]
|
||||
|
||||
list1.append(6)
|
||||
|
||||
# 2.使用list()创建
|
||||
list2 = list('hello')
|
||||
|
||||
print(list1,list2)
|
||||
|
||||
# 3.使用+ 连接两个列表
|
||||
list3 = list1 + list2
|
||||
print(list3)
|
||||
|
||||
|
||||
# 使用 + 不改变原列表, 使用+= 更改原列表
|
||||
# 使用append()改变原列表
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# 变量占位符
|
||||
name = 'lichao'
|
||||
age = 25
|
||||
money = 9.535
|
||||
|
||||
# 一种用法
|
||||
print("姓名:%s,年龄:%d,余额:%.2f" % (name, age, money))
|
||||
|
||||
#py 3.6以上的版本可以使用
|
||||
print(f"姓名:{name},年龄:{age},余额:{money:.2f}")
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : 字符串切片.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/20 15:41
|
||||
@Software : PyCharm
|
||||
"""
|
||||
|
||||
string = 'abcdef'
|
||||
|
||||
# 左闭右开
|
||||
print(string[1:3]) # bc
|
||||
|
||||
print(string[2:]) # cdef
|
||||
|
||||
# 负数索引表示从右往左
|
||||
print(string[:-1]) # abcde
|
||||
|
||||
# 省略索引,表示全部
|
||||
print(string[:]) # abcdef
|
||||
|
||||
# 步长 第三个参数 ,间隔为 步长 - 1
|
||||
print(string[::2]) # ace
|
||||
print(string[:4:3]) # ad
|
||||
|
||||
# 步长为负数,表示从右往左,开始要大于结束
|
||||
|
||||
print(string[4:1:-1]) # edc
|
||||
|
||||
# 字符串倒序
|
||||
print(string[::-1]) # fedcba
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : 字符串方法.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/20 16:01
|
||||
@Software : PyCharm
|
||||
"""
|
||||
|
||||
string_data = 'testData'
|
||||
|
||||
print(string_data.find('D',0,1)) # -1
|
||||
|
||||
print(string_data.count('a'))
|
||||
|
||||
print(string_data.replace('a', 'A',1)) # testDAta
|
||||
|
||||
string_data2 = 'a,b,c,d,e'
|
||||
|
||||
print(string_data2.split(',')) # ['a', 'b', 'c', 'd', 'e']
|
||||
|
||||
string_data3 = ' hello '
|
||||
|
||||
print(string_data3.strip()) # hello
|
||||
|
||||
string_data4 = '12313aaa'
|
||||
|
||||
print(string_data4.isdigit()) # false
|
||||
print(string_data4.isalnum()) # True
|
||||
|
||||
symbol = ','
|
||||
strings = ['a','b','c','d','e']
|
||||
print(symbol.join(strings)) # a,b,c,d,e
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : 打印99乘法表.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/26 17:03
|
||||
@Software : PyCharm
|
||||
"""
|
||||
|
||||
for i in range(1, 10):
|
||||
for j in range(1, i + 1):
|
||||
print(f' {i * j}', end=' ')
|
||||
print()
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import requests
|
||||
import os
|
||||
import math
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
# 获取用户输入的 API 密钥和搜索关键字
|
||||
search_query = input("请输入你想搜索的图片类型:")
|
||||
total_images = int(input("请输入你想下载的图片数量:"))
|
||||
|
||||
# 设置基本参数
|
||||
params = {
|
||||
'key': os.getenv('API_KEY'),
|
||||
'q': search_query,
|
||||
'image_type': 'photo',
|
||||
'pretty': 'true',
|
||||
'per_page': 200 # 每页最多下载 200 张图片
|
||||
}
|
||||
|
||||
# 计算需要的页数
|
||||
images_per_page = params['per_page']
|
||||
num_pages = math.ceil(total_images / images_per_page)
|
||||
|
||||
# 创建保存图片的目录
|
||||
save_dir = f'./Pixabay_{search_query}_Images'
|
||||
if not os.path.exists(save_dir):
|
||||
os.makedirs(save_dir)
|
||||
|
||||
# 定义函数用于下载每页的图片
|
||||
def download_images(page_number, remaining_images):
|
||||
params['page'] = page_number
|
||||
response = requests.get('https://pixabay.com/api/', params=params)
|
||||
data = response.json()
|
||||
|
||||
if 'hits' in data:
|
||||
for i, image in enumerate(data['hits']):
|
||||
if remaining_images <= 0:
|
||||
break
|
||||
img_url = image['webformatURL']
|
||||
img_data = requests.get(img_url).content
|
||||
img_path = os.path.join(save_dir, f"{search_query}_page_{page_number}_img_{i + 1}.jpg")
|
||||
with open(img_path, 'wb') as file:
|
||||
file.write(img_data)
|
||||
remaining_images -= 1
|
||||
print(f"已下载:{img_path}")
|
||||
else:
|
||||
print(f"在第 {page_number} 页没有找到相关图片。")
|
||||
return remaining_images
|
||||
|
||||
# 下载图片直到总数达到用户指定的数量
|
||||
remaining_images = total_images
|
||||
for page in range(1, num_pages + 1):
|
||||
remaining_images = download_images(page, remaining_images)
|
||||
if remaining_images <= 0:
|
||||
break
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
import os
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib.parse import urljoin
|
||||
|
||||
|
||||
# 创建保存图片的目录
|
||||
def create_directory(directory):
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
|
||||
# 下载图片
|
||||
def download_image(url, folder_path):
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
if response.status_code == 200:
|
||||
# 从URL中获取文件名
|
||||
filename = os.path.join(folder_path, url.split("/")[-1])
|
||||
with open(filename, 'wb') as file:
|
||||
for chunk in response.iter_content(1024):
|
||||
file.write(chunk)
|
||||
print(f"图片下载成功: {filename}")
|
||||
else:
|
||||
print(f"图片下载失败: {url}")
|
||||
except Exception as e:
|
||||
print(f"下载过程中出现错误: {e}")
|
||||
|
||||
|
||||
# 爬取网页中的图片
|
||||
def scrape_images(url, folder_path="downloaded_images"):
|
||||
create_directory(folder_path)
|
||||
|
||||
# 发送HTTP请求获取网页内容
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
|
||||
# 查找所有<img>标签
|
||||
img_tags = soup.find_all('img')
|
||||
|
||||
# 遍历所有图片标签,获取图片URL并下载
|
||||
for img in img_tags:
|
||||
img_url = img.get('src')
|
||||
if not img_url:
|
||||
continue
|
||||
|
||||
# 转换为绝对URL(有些网站使用相对路径)
|
||||
img_url = urljoin(url, img_url)
|
||||
|
||||
# 下载图片
|
||||
download_image(img_url, folder_path)
|
||||
|
||||
|
||||
# 示例使用
|
||||
url = "https://lcdd.net" # 你想要爬取的网页URL
|
||||
scrape_images(url)
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : getDomain.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/25 16:09
|
||||
@Software : PyCharm
|
||||
"""
|
||||
|
||||
import whois
|
||||
import concurrent.futures
|
||||
from get_Combine import generate_combinations
|
||||
|
||||
|
||||
def check_domain_registration(domain):
|
||||
try:
|
||||
# 使用 whois 查询域名信息
|
||||
domain_info = whois.whois(domain)
|
||||
|
||||
# 如果是 .de 域名,直接检查 Status 字段
|
||||
if domain.endswith(".de"):
|
||||
status_line = domain_info.get('status', '').lower()
|
||||
if 'free' in status_line:
|
||||
return (domain, False) # 域名未注册
|
||||
else:
|
||||
return (domain, True) # 域名已注册
|
||||
|
||||
# 判断返回的数据是否为空,通常空数据表示域名未注册
|
||||
if domain_info is None or not domain_info.domain_name:
|
||||
return (domain, False)
|
||||
else:
|
||||
return (domain, True)
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并处理未注册的情况
|
||||
return (domain, False)
|
||||
|
||||
|
||||
def check_domains_in_parallel(domains):
|
||||
results = []
|
||||
|
||||
# 使用 ThreadPoolExecutor 进行并行查询
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
||||
# 提交所有查询任务
|
||||
future_to_domain = {executor.submit(check_domain_registration, domain): domain for domain in domains}
|
||||
|
||||
# 获取查询结果
|
||||
for future in concurrent.futures.as_completed(future_to_domain):
|
||||
domain = future_to_domain[future]
|
||||
try:
|
||||
result = future.result()
|
||||
results.append(result)
|
||||
except Exception as exc:
|
||||
print(f"{domain} 产生了一个异常: {exc}")
|
||||
|
||||
return results
|
||||
|
||||
# strings = generate_combinations(1,'.de')
|
||||
#
|
||||
# print(len(strings),strings)
|
||||
|
||||
# 测试例子
|
||||
domains_to_check = [
|
||||
".de",
|
||||
]
|
||||
|
||||
# 并行查询
|
||||
results = check_domains_in_parallel(domains_to_check)
|
||||
|
||||
# 打印结果
|
||||
for domain, is_registered in results:
|
||||
if is_registered:
|
||||
print(f"域名 {domain} 已被注册。")
|
||||
else:
|
||||
print(f"域名 {domain} 未被注册。")
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
from itertools import combinations
|
||||
|
||||
|
||||
def generate_combinations(n, suffix):
|
||||
# 所有可能的单个字母
|
||||
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
# 对 n=1 的特殊处理
|
||||
if n == 1:
|
||||
return [c + suffix for c in letters]
|
||||
|
||||
# 1. n 个字母完全相同的组合
|
||||
repeated_combinations = [c * n for c in letters]
|
||||
|
||||
# 2. (n-1) 个字母相同,一个不同的组合 (仅当 n > 1)
|
||||
double_repeats = []
|
||||
if n > 1:
|
||||
for c1 in letters:
|
||||
for c2 in letters:
|
||||
if c1 != c2:
|
||||
# 确保字母按字母表顺序排列,避免重复
|
||||
combination = ''.join(sorted([c1] * (n - 1) + [c2]))
|
||||
if combination not in double_repeats:
|
||||
double_repeats.append(combination)
|
||||
|
||||
# 3. n 个字母不完全相同的组合 (仅当 n > 1)
|
||||
unique_combinations = []
|
||||
if n > 1:
|
||||
unique_combinations = [''.join(sorted(comb)) for comb in combinations(letters, n) if len(set(comb)) == n]
|
||||
|
||||
# 合并所有组合
|
||||
all_combinations = repeated_combinations + double_repeats + unique_combinations
|
||||
|
||||
# 将所有组合拼接后缀
|
||||
final_combinations = [combo + suffix for combo in all_combinations]
|
||||
|
||||
return final_combinations
|
||||
|
||||
if __name__ == '__main__':
|
||||
n = 2 # 可以输入不同的长度
|
||||
suffix = '.de' # 可以输入不同的后缀
|
||||
|
||||
# 生成组合并打印
|
||||
combinations = generate_combinations(n, suffix)
|
||||
print(combinations)
|
||||
print(f"生成的组合数量: {len(combinations)}")
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
import time
|
||||
import logging
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s")
|
||||
|
||||
# 配置邮件发送函数
|
||||
def send_email(subject, body, to_email):
|
||||
# 邮件服务器配置
|
||||
smtp_server = "smtp.lcdd.net"
|
||||
smtp_port = 587
|
||||
from_email = "admin@lcdd.net"
|
||||
password = "lichao1314"
|
||||
|
||||
# 构建邮件
|
||||
msg = MIMEMultipart()
|
||||
msg["From"] = from_email
|
||||
msg["To"] = to_email
|
||||
msg["Subject"] = subject
|
||||
msg.attach(MIMEText(body, "plain"))
|
||||
|
||||
# 连接到服务器并发送邮件
|
||||
try:
|
||||
with smtplib.SMTP(smtp_server, smtp_port) as server:
|
||||
server.starttls()
|
||||
server.login(from_email, password)
|
||||
server.sendmail(from_email, to_email, msg.as_string())
|
||||
logging.info("邮件已发送到 %s", to_email)
|
||||
except Exception as e:
|
||||
logging.error("邮件发送失败: %s", e)
|
||||
|
||||
# 配置爬虫任务
|
||||
def check_website_for_condition(url, keyword):
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status() # 确保请求成功
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
|
||||
# 搜索关键词
|
||||
if keyword in soup.get_text():
|
||||
logging.info("检测到关键词: %s", keyword)
|
||||
return True
|
||||
else:
|
||||
logging.info("关键词 %s 不存在", keyword)
|
||||
return False
|
||||
except Exception as e:
|
||||
logging.error("请求失败: %s", e)
|
||||
return False
|
||||
|
||||
# 主调度函数
|
||||
def monitor_website():
|
||||
url = "https://lcdd.net" # 目标网址
|
||||
keyword = "React" # 目标关键词
|
||||
to_email = "randolphreidhdu@gmail.com" # 收件人邮箱
|
||||
|
||||
# 监控循环
|
||||
while True:
|
||||
if check_website_for_condition(url, keyword):
|
||||
subject = "关键词检测通知"
|
||||
body = f"目标网站 {url} 上检测到关键词 '{keyword}' 出现!"
|
||||
send_email(subject, body, to_email)
|
||||
break # 如果检测到条件,发送一次邮件并退出循环
|
||||
|
||||
# 未检测到条件时,延迟一段时间再次检查
|
||||
time.sleep(300) # 每5分钟检查一次
|
||||
|
||||
# 启动监控
|
||||
if __name__ == "__main__":
|
||||
monitor_website()
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : simple.py
|
||||
@Author : lichao
|
||||
@Date : 2024/11/25 16:39
|
||||
@Software : PyCharm
|
||||
"""
|
||||
|
||||
import requests
|
||||
import string
|
||||
|
||||
|
||||
def gen_combos():
|
||||
chars = string.ascii_lowercase + string.digits
|
||||
combos = []
|
||||
for char1 in chars:
|
||||
for char2 in chars:
|
||||
for char3 in chars:
|
||||
combos.append(char1 + char2 + char3)
|
||||
return combos
|
||||
|
||||
|
||||
def find(base_url, combos):
|
||||
for combo in combos:
|
||||
url = f"{base_url}{combo}.de"
|
||||
print(combo, end="")
|
||||
try:
|
||||
response = requests.get(url)
|
||||
if "is free and available for registration." in response.text:
|
||||
print(".de 可注册")
|
||||
else:
|
||||
print()
|
||||
except requests.RequestException as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def main():
|
||||
base_url = "https://webwhois.denic.de/?lang=en&query="
|
||||
combos = gen_combos()
|
||||
find(base_url, combos)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue