# -*- coding: utf-8 -*- import re import httpx # 设置代理,包含协议部分 proxies = { "http://": "http://127.0.0.1:7890", "https://": "http://127.0.0.1:7890", } # 设置请求头 headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107" } # 创建 httpx 客户端,并设置代理和请求头 client = httpx.Client(proxies=proxies, headers=headers) # 目标 URL # url = "https://coinmarketcap.com/currencies/sui/" # sui url = "https://coinmarketcap.com/currencies/x/" # x try: result = '' resp = client.get(url) page = resp.text text = re.findall('(.*?)sc-65e7f566-0', page)[0] if re.findall( '(.*?)sc-65e7f566-0', page) else 'No Data' text = re.sub(r'', '', text) text = re.sub(r'', '', text) text = re.sub(r'