byomkesh
A courteous truth-seeker for news article text.
Facts
- Repository github.com/AtriMukherjee/byomkesh
- Licence NOASSERTION
- Version 0.2.0
- Latest commit 2026-12-02
library(byomkesh)
byomkesh("links.csv",
"news.jsonl",
patterns = "charli\\s*xcx")
What it is
byomkesh is a text scraper for news research, written as an R package. It takes a list of news URLs, for example a Media Cloud export, and brings back the full text of each article, together with metadata and counts of your keywords. It is built for media and communication researchers who want news texts for qualitative, quantitative and computational analyses, and it is named after Sharadindu Bandyopadhyay's detective Byomkesh Bakshi. It is my first open-source tool, so expect the occasional bug.
How it works
- You supply a CSV with a
urlcolumn (and optionally anidcolumn). - For each link, byomkesh reads the site's
robots.txtand waits between visits to the same site. - It downloads the page and extracts the article text and metadata.
- It counts your keywords (any script, Devanagari included) and saves the surrounding passages.
- If a story has been taken down, it can look for a copy in the Internet Archive.
- Results are written line by line, so a stopped run carries on where it left off.
Use
install.packages("byomkesh", repos = c("https://atrimukherjee.r-universe.dev",
"https://cloud.r-project.org"))
library(byomkesh)
byomkesh("my_links.csv", "my_articles.jsonl",
email = "you@university.edu",
patterns = "your keyword")
articles <- read_results("my_articles.jsonl")
The README in the repository has a worked example, all options, and a command-line version for long runs.
Output
One row per link, as JSONL or CSV: the final URL, a status (ok, http_error, robots_blocked and so on), fetch time, title, author, date, language, word count, keyword hits, context passages and the full text.
Stack
R (4.1 or newer) with httr, xml2, jsonlite and digest.
Limitations
- Text extraction is a guess about where the article sits on the page. Some site designs fool it, and paywall messages or cookie banners can pass as articles. Read a sample from every outlet before trusting results.
- Sites that block automated visitors return errors; longer delays or archived copies help in some cases.
- It extracts text only, not images, video or paywalled content.
Ethics and legal note
byomkesh honours robots.txt and Crawl-delay, pauses between visits, identifies you by email so site owners can reach you, and records pages that robots rules exclude instead of fetching them. Switching off the robots check is only for sites that have given permission. Please also check each site's terms of service before collecting from it. Article texts belong to their publishers: use them for analysis and, when sharing data, share links, codes or counts rather than full texts. If texts include personal data such as names of private individuals, data protection law (GDPR in the EU) applies to how you store and share them, and your ethics board or data protection officer should be consulted.