代码拉取完成,页面将自动刷新
# convert the urls in README.md to json format, and save it to urls.json, colapse the same urls, remove the last `/` in the url
import json
import re
# Read the content of README.md
with open("README.md", "r", encoding="utf-8") as file:
content = file.read()
# Stop reading when reaching a line that contains '### 🚫 已失效'
content = content.split('### 🚫 已失效')[0]
# Find all URLs in the content []
urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+(?=\])', content)
# urls = re.findall(r'(?<!~~)(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)(?!~~)', content)
# Remove the last '/' in the URL and collapse the same URLs
unique_urls = []
for url in urls:
url = url[:-1] if url.endswith('/') else url
if url not in unique_urls:
unique_urls.append(url)
# Save the URLs to urls.json
with open("urls.json", "w") as file:
json.dump(unique_urls, file)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。