如果你可以运行到python代码的话
找某网页所有data-id的代码︰
____________________________________________________________-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
# 设置Chrome选项,启用Headless模式
chrome_options = Options()
chrome_options.add_argument('--headless') # 不显示浏览器界面
# 初始化 WebDriver
driver = webdriver.Chrome(options=chrome_options)
# 让用户输入网址
url = input("请输入目标网页的网址:")
# 打开目标网页
driver.get(url)
# 等待页面加载
time.sleep(5)
# 通过XPath提取所有带有data-id的div元素
xpath = "//div[@data-id]"
elements = driver.find_elements(By.XPATH, xpath)
# 提取所有的data-id,并过滤非7位数字的
data_ids = [
element.get_attribute("data-id") for element in elements
if element.get_attribute("data-id") and len(element.get_attribute("data-id")) == 7 and element.get_attribute("data-id").isdigit()
]
# 打印出所有符合条件的7位数字的data-id
print(f"Found 7-digit data-ids: {data_ids}")
# 关闭浏览器
driver.quit()
___________________________________________________________________
我会尝试整合这个代码到一个网址上,如完成会补充网址在这里()
登录你的豆瓣,找到你的ck=xxxx(比如我的是"a6-C")
其中"7393924"是特定data-id(上文已说明寻找方法),"a6-C"是特定ck(依赖你的豆瓣帐号)
故有形式
"https://m.douban.com/rexxar/api/v2/ceorl/poll/question/{data-id}?ck={你的ck}"
得到形如下correct_answer
例如"correct_answer": "\u5979\u5e26\u4e00\u7fa4\u4eba\u56f4\u6bb4\u6211\uff0c\u6211\u5c31\u6c14\u8131\u7c89\u4e86\uff0c\u6211\u89c9\u5f97\u6211\u8bf4\u5f97\u4f60\u6ca1\u9519\uff0c\u4f60\u4e0d\u4e5f\u9a82\u5417\uff0c\u6211\u8fd8\u82b1\u94b1\u9a82\u4e86"
得到
"在美团外卖小程序收藏店铺,收藏的店铺卡片发给c1n公众号,复制它发过来的全部内容"
或运行此python代码以解码
_______________________________________________________________________
import json
# 获取用户输入的 Unicode 字符串
unicode_str = input("请输入需要解码的 Unicode 字符串:")
# 使用 json.loads() 解码 Unicode 字符串
decoded_str = json.loads(f'"{unicode_str}"')
# 输出解码后的结果
print(f"解码后的内容是: {decoded_str}")
_________________________________________________________________________
同样地,我会尝试整合这个代码到同一个网址上,如完成会补充网址在这里()
评论
发表评论