You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.9 KiB
69 lines
2.9 KiB
import httpx
|
|
from bs4 import BeautifulSoup
|
|
|
|
proxy = "http://127.0.0.1:7890"
|
|
|
|
|
|
def get_lottery_info(url):
|
|
headers = {
|
|
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
"accept-encoding": "gzip, deflate, br, zstd",
|
|
"accept-language": "zh-CN,zh;q=0.9",
|
|
"cache-control": "max-age=0",
|
|
"cookie": 'wagmi.store={"state":{"connections":{"__type":"Map","value":[]},"chainId":42161,"current":null},"version":2}; _ga=GA1.1.1564597071.1751872255; _ga_F9J18S6WJV=GS2.1.s1751946352$o3$g1$t1751946355$j57$l0$h0; ph_phc_9sSugZ5bXYldHSU4TaDf0jB2RBFxxCLFKQ91N6CqWhL_posthog=%7B%22distinct_id%22%3A%220197e3b9-3085-7350-9fed-4a9ef545e3ab%22%2C%22%24sesid%22%3A%5Bnull%2Cnull%2Cnull%5D%7D',
|
|
"priority": "u=0, i",
|
|
"sec-ch-ua": '"Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140"',
|
|
"sec-ch-ua-mobile": "?0",
|
|
"sec-ch-ua-platform": '"macOS"',
|
|
"sec-fetch-dest": "document",
|
|
"sec-fetch-mode": "navigate",
|
|
"sec-fetch-site": "same-origin",
|
|
"sec-fetch-user": "?1",
|
|
"upgrade-insecure-requests": "1",
|
|
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
|
|
}
|
|
|
|
with httpx.Client(proxies={"http://": proxy, "https://": proxy}) as client:
|
|
response = client.get(url, headers=headers)
|
|
|
|
if response.status_code != 200:
|
|
print(f"请求失败,状态码: {response.status_code}")
|
|
return None
|
|
|
|
html = response.text
|
|
soup = BeautifulSoup(html, "html.parser")
|
|
|
|
data = {}
|
|
title_script_tags = soup.select("body > div.flex.flex-col.flex-nowrap.min-h-dvh.relative.pb-\[66px\].sm\:pb-0 > main > div.flex-1.max-w-\[100vw\].w-full > section > div > div.flex.justify-between.flex-col.w-full.md\:flex-row.sm\:justify-center > div > div.flex.flex-col.px-0.sm\:mb-5.w-full.sm\:px-0.sm\:py-0.sm\:flex-row.sm\:justify-between.sm\:gap-\[72px\] > div > div.flex.gap-2.mt-4.sm\:mt-5.sm\:gap-4 > div.font-mona.flex-1.flex.items-center.line-clamp-2.text-size-20.sm\:text-size-28.mh-20.font-extrabold")
|
|
description_script_tags = soup.select("#radix-«r2d» > div.flex-1.overflow-y-auto.mt-6.sm\:mt-7 > div > div")
|
|
|
|
print(description_script_tags)
|
|
|
|
for description_script_tag in description_script_tags:
|
|
print(description_script_tag.text)
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
def main():
|
|
url = "https://app.galxe.com/quest/tiktrix/GCqaRtftKv"
|
|
result = get_lottery_info(url)
|
|
if not result:
|
|
print("获取数据失败")
|
|
return
|
|
|
|
if len(result) == 0:
|
|
print("获取数据失败")
|
|
return
|
|
|
|
try:
|
|
for data in result:
|
|
print(data.text) # 打印标签中的文本内容
|
|
except Exception as e:
|
|
print('数据格式错误: {}'.format(e))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|