1 Star 4 Fork 0

wangce888 / awesome-free-chatgpt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
convert.py 985 Bytes
一键复制 编辑 原始数据 按行查看 历史
# 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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangce888/awesome-free-chatgpt.git
git@gitee.com:wangce888/awesome-free-chatgpt.git
wangce888
awesome-free-chatgpt
awesome-free-chatgpt
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891