提交 cbeefd91 编写于 作者: R root

Thu Jul 17 10:47:00 CST 2025 inscode

上级 0a575cc3
print('欢迎来到 InsCode') #!/usr/bin/env/ python
\ No newline at end of file # -*- coding:utf-8 -*-
# [url=home.php?mod=space&uid=686208]@AuThor[/url] : zxy
import time
import requests
from lxml import etree
url = "https://mfyx.top/api/search"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
}
org_url = input("请输入知乎盐选文章的分享地址:")
data = {"url": [org_url]}
response = requests.post(url=url, json=data, headers=headers).json()
# print(response)
arc_id = response["id"]
title = response["title"].replace("?", "")
des = response["description"]
new_url = f"https://mfyx.top/archives/{arc_id}"
res = requests.get(new_url, headers=headers).text
# print(res)
# xpath://*[@id="lightgallery"]/p
html = etree.HTML(res)
p = html.xpath('//*[@id="lightgallery"]/p/text()')
# print(type(p), p)
print(f"小主为您找到文章的简介:\n{des}")
time.sleep(3)
start = time.time()
with open(f"{title}.txt", "w", encoding="utf-8") as f:
for each_line in p:
f.write(each_line + "\n")
end = time.time()
print(f"[{title}]文章下载完毕,共耗时{end - start:.2f}秒")
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册