first commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
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()
|
||||
@@ -0,0 +1,28 @@
|
||||
import time
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
def extract_content():
|
||||
with sync_playwright() as p:
|
||||
# 启动浏览器(无头)模式并设置代理
|
||||
browser = p.chromium.launch(headless=True, proxy={"server": "http://127.0.0.1:7890"})
|
||||
page = browser.new_page()
|
||||
|
||||
url = "https://app.galxe.com/quest/tiktrix/GCqaRtftKv"
|
||||
page.goto(url)
|
||||
|
||||
page.wait_for_load_state()
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
selector = r'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'
|
||||
content_elements = page.query_selector_all(selector)
|
||||
|
||||
if content_elements:
|
||||
for element in content_elements:
|
||||
print(element.text_content())
|
||||
|
||||
# 关闭浏览器
|
||||
browser.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
extract_content()
|
||||
@@ -0,0 +1,2 @@
|
||||
l = "__typename":"Campaign","id":"GCqaRtftKv","numberID":346610,"name":"Win a Share of 1,000 USDT u0026 50,000 $TRIX Airdrop (FCFS)","description":"TikTrix transforms social engagement by combining short-form media with casual gaming. nn**Complete these simple steps to join the TikTrix quest and claim your rewards**nn⚡️ FCFS Airdrop on TikTrixn20 $TRIX for the first 2,500 verified users on TikTrix Event page (total: 50,000 $TRIX)nn🎟️ Rafflen1,000 USDT raffle for users who complete the quest (100 winners will receive 10 USDT each)nn🎯 Just complete these 3 simple steps:n- Visit our event pagen- Join our Discordn- Follow us on Twittern","startTime":1751533200,"endTime":1752138000,"status":"Active","type":"Token","chain":"MATIC","inWatchList":false,"bannerUrl":"","watchlistPro":null,"participants":{"__typename":"CampaignParticipant","participants":{"__typename":"ParticipantsConnection","list":[{"__typename":"ParticipationRecord","address":{"__typename":"Address","id":"ch8taW4SJz7dadCdip7LNb","avatar":"https://api.galxe.com/v1/avatar?size=120u0026variant=marbleu0026name=0x000014d697d9040bd9c32904a3b1c821e83da4d4"}
|
||||
print(len(l))
|
||||
Reference in New Issue
Block a user