🤗更加合理的请求头

This commit is contained in:
2025-05-03 15:45:52 +08:00
parent ec4328cbe0
commit 5b47d2d3bc
3 changed files with 163 additions and 73 deletions

View File

@ -6,10 +6,17 @@ import json
import os
# 标准化的请求头
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
HEADERS_JSON = {
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/123.0.0.0 Safari/537.36 "
"(Friend-Circle-Lite/1.0; +https://github.com/willow-god/Friend-Circle-Lite)"
),
"X-Friend-Circle": "1.0"
}
def extract_emails_from_issues(api_url):
"""
从GitHub issues API中提取以[e-mail]开头的title中的邮箱地址。
@ -26,7 +33,7 @@ def extract_emails_from_issues(api_url):
}
"""
try:
response = requests.get(api_url, headers=headers)
response = requests.get(api_url, headers=HEADERS_JSON, timeout=10)
response.raise_for_status()
issues = response.json()
except Exception as e: