Skip to content

Fix for Python 3.9+/current arXiv + switch to the official arXiv API - #38

Open
svemulapati wants to merge 2 commits into
chiphuyen:masterfrom
svemulapati:fix/modernize-and-use-arxiv-api
Open

svemulapati wants to merge 2 commits into
chiphuyen:masterfrom
svemulapati:fix/modernize-and-use-arxiv-api

Conversation

@svemulapati

Copy link
Copy Markdown

Summary

This PR gets sotawhat working again on modern Python and a current arXiv, and makes it resilient to future arXiv changes. The script had stopped working on Python 3.9+ and against arXiv's current site.

Fixes (script was broken on Python 3.9+ / current arXiv)

  • Replace removed HTMLParser.unescape() with html.unescape() (removed in Python 3.9).
  • Fix garbled paper links and author-name mojibake (proper UTF-8 decoding of the response).
  • Auto-configure SSL via certifi, so nltk downloads and arXiv requests work on macOS without the manual "Install Certificates" step.

Improvement: use the official arXiv API

  • Switch from scraping arXiv's search HTML to the official, public, no-registration arXiv API, parsing the structured Atom XML with xml.etree.ElementTree. This removes the brittleness that broke the tool whenever arXiv changed its page layout.
  • Polite >= 3s delay between paged requests, per arXiv's API terms of use.
  • Drop the now-unused six dependency.

Unchanged

  • CLI: sotawhat <keyword> [count] (default 5).
  • Output format (title, author, date, summary, link).
  • The abstract-summarization behavior that prioritizes sentences with numbers / SOTA claims.
  • Keyword-based CS-only filtering for plain English words, all-of-arXiv for jargon.

Tested locally across several keywords (transformer, language model, perplexity, GAN, wikitext) plus the no-result path.

🤖 Generated with Claude Code

svemulapati and others added 2 commits June 19, 2026 06:08
- Replace removed HTMLParser.unescape() with html.unescape()
- Extract abs/pdf links via regex instead of brittle line offsets
  (arXiv inserted a wrapper div, breaking the old index math)
- Decode arXiv response as UTF-8 to fix author-name mojibake
- Auto-configure SSL via certifi so nltk/arXiv requests work on
  macOS without manual cert setup
- Add .gitignore for venv/build artifacts

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Query export.arxiv.org/api/query (public, no registration) and parse the
returned Atom XML with ElementTree, replacing the brittle search-page
scraper that broke whenever arXiv changed its HTML layout.

- Robust XML parsing of title/abstract/authors/date/links
- Keyword-based CS-only filtering via 'cat:cs.*' for plain English words,
  all-of-arXiv for jargon (preserves original behavior)
- Client-side pagination with a polite >=3s delay between requests
- Keep the abstract-summarization logic (numbers/SOTA prioritization)
- Drop now-unused 'six' dependency

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant