forked from WangRongsheng/ChatGenTitle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_daily_llm_paper.py
37 lines (27 loc) · 1.1 KB
/
get_daily_llm_paper.py
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
26
27
28
29
30
31
32
33
34
35
36
37
import requests
import xml.etree.ElementTree as ET
base_url = "https://export.arxiv.org/api/query?"
search_query = "large+language+models"
start = 0
max_results = 30
query = f"search_query=all:{search_query}&start={start}&max_results={max_results}"
url = base_url + query
response = requests.get(url)
if response.status_code == 200:
print("获取论文成功!")
# 解析XML响应
root = ET.fromstring(response.text)
# 打开用于保存结果的Markdown文件
with open("LLMs-papers.md", "w+", encoding="utf-8") as md_file:
print("读取成功")
# 提取每篇论文的链接和标题
c = 1
for entry in root.findall('{https://www.w3.org/2005/Atom}entry'):
link = entry.find('{https://www.w3.org/2005/Atom}id').text
title = entry.find('{https://www.w3.org/2005/Atom}title').text
# 将标题和链接写入Markdown文件
md_file.write(str(c)+f". [{title}]({link})\n")
c = c+1
print("论文信息已保存到papers.md文件!")
else:
print("获取论文失败")