Spaces:
Running
Running
File size: 902 Bytes
a235177 1748047 a235177 49cee1b 3d2bc32 a235177 98aa43b a235177 49cee1b a235177 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
import xmltodict
import requests
def search(q,rn):
r=requests.get(api.replace("SQ",q).replace("MR",str(rn)))
cont=xmltodict.parse(r.content)['feed']['entry']
html=""
for i,c in enumerate(cont):
pdflink=c['id'].replace('/abs/','/pdf/')
html+=f"<div class='card_div' id='id{i}' onclick='fun_run()'>"
html+=f"<div class='titlebase'>{c['title']}</div>"
html+=f"<div>{c['summary']}</div>"
html+=f"<div><a href='{pdflink}' target='_blank'>{pdflink}</a></div>"
html+="</div>"
return(json.dumps(cont,indent=4)),html
with gr.Blocks() as b:
with gr.Group():
with gr.Row():
query=gr.Textbox(label="Query")
num=gr.Number(label="Count",step=1,value=10)
sub=gr.Button()
html_out=gr.HTML()
json_out=gr.JSON()
sub.click(search,[query,num],[json_out,html_out])
b.launch() |