pdx97 commited on
Commit
6dda0fd
·
verified ·
1 Parent(s): d54a2bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -338,15 +338,17 @@ def fetch_latest_arxiv_papers(keywords: list, num_results: int = 5) -> list:
338
  List of the most relevant papers based on TF-IDF ranking.
339
  """
340
  try:
341
- # ✅ Fetch only 5 papers
342
- url = f"http://export.arxiv.org/api/query?search_query={'%20'.join(keywords)}&start=0&max_results=5&sortBy=submittedDate&sortOrder=descending"
343
- print(f"DEBUG: Query URL - {url}")
 
 
 
344
 
345
  feed = feedparser.parse(url)
346
  print(f"DEBUG: API Response - {feed.entries}")
347
 
348
  papers = []
349
-
350
  for entry in feed.entries:
351
  papers.append({
352
  "title": entry.title,
 
338
  List of the most relevant papers based on TF-IDF ranking.
339
  """
340
  try:
341
+ # ✅ Correct URL encoding for spaces and special characters
342
+ query = "+AND+".join([f"all:{kw}" for kw in keywords])
343
+ query_encoded = urllib.parse.quote_plus(query) # FIXED: Correct encoding
344
+
345
+ url = f"http://export.arxiv.org/api/query?search_query={query_encoded}&start=0&max_results=5&sortBy=submittedDate&sortOrder=descending"
346
+ print(f"DEBUG: Query URL - {url}") # ✅ Debugging
347
 
348
  feed = feedparser.parse(url)
349
  print(f"DEBUG: API Response - {feed.entries}")
350
 
351
  papers = []
 
352
  for entry in feed.entries:
353
  papers.append({
354
  "title": entry.title,