魔法师
2024-01-11 17:18 deepin
这个小工具是发前面贴顺便写的
http 粘贴自动变成 https ,刚改
展开 streamlit 代码
import streamlit as st
import requests
import json
def _max_width_(prcnt_width:int = 75):
max_width_str = f"max-width: {prcnt_width}rem;"
st.markdown(f"""
""",
unsafe_allow_html=True,
)
_max_width_(st.sidebar.slider('屏幕占比', 50, 100, 75))
st.title("往日荣耀")
format = '- [{}](https://bbs.deepin.org/post/{})'
# https://bbs.deepin.org/post/265585
# subject
# id
@st.cache_data
def getcontent(url):
return requests.get(url).content.decode()
limit = st.sidebar.slider('数据范围', 30, 500, 30)
uid = st.text_input("访问数据(输入uid)", value="10000")
content = getcontent(f'https://bbs.deepin.org/api/v1/user/thread?id={uid}&limit={limit}')
data = json.loads(content)['data']
contents = []
datasources = []
v = st.text_input('filter')
print(len(data))
for index, item in enumerate(data):
id = item['id']
subject = item['subject']
if v == "" or v in subject:
contents.append(format.format(subject,id))
datasources.append({
'id': index+1,
"title": subject,
'url': f'https://bbs.deepin.org/post/{id}'
})
if st.checkbox('显示为可复制 markdown 代码或表格'):
st.code('\n'.join(contents))
else:
st.dataframe(datasources, column_config={
'url': st.column_config.LinkColumn('Url')
},use_container_width=True)
import streamlit as st
import requests
import json
def _max_width_(prcnt_width:int = 75):
max_width_str = f"max-width: {prcnt_width}rem;"
st.markdown(f"""
""",
unsafe_allow_html=True,
)
_max_width_(st.sidebar.slider('屏幕占比', 50, 100, 75))
st.title("往日荣耀")
format = '- [{}](https://bbs.deepin.org/post/{})'
# https://bbs.deepin.org/post/265585
# subject
# id
@st.cache_data
def getcontent(url):
return requests.get(url).content.decode()
limit = st.sidebar.slider('数据范围', 30, 500, 30)
uid = st.text_input("访问数据(输入uid)", value="10000")
content = getcontent(f'https://bbs.deepin.org/api/v1/user/thread?id={uid}&limit={limit}')
data = json.loads(content)['data']
contents = []
datasources = []
v = st.text_input('filter')
print(len(data))
for index, item in enumerate(data):
id = item['id']
subject = item['subject']
if v == "" or v in subject:
contents.append(format.format(subject,id))
datasources.append({
'id': index+1,
"title": subject,
'url': f'https://bbs.deepin.org/post/{id}'
})
if st.checkbox('显示为可复制 markdown 代码或表格'):
st.code('\n'.join(contents))
else:
st.dataframe(datasources, column_config={
'url': st.column_config.LinkColumn('Url')
},use_container_width=True)
Reply Like 0 View the author
点击访问 http://hk.shenmo.tech/查看往日荣耀
操作说明
PS: 只写一个