Create bibliography citations from web page URLs with automatic Wayback Machine archival and metadata extraction...
Create bibliography citations from web page URLs with automatic archival snapshot and metadata extraction.
npx tsx plugins/bib/scripts/cite-web.ts <url>
npx tsx plugins/bib/scripts/cite-web.ts <url> --format=bibtex
npx tsx plugins/bib/scripts/cite-web.ts <url> --no-wayback
npx tsx plugins/bib/scripts/cite-web.ts <url> --output=citations.bib
The script extracts metadata from semantic HTML tags:
<title> tag<meta property="og:title"><meta name="twitter:title"><meta name="title"><meta name="author"><meta property="og:author"> or <meta property="article:author"><meta name="twitter:creator"><meta name="description"><meta property="og:description"><meta name="twitter:description"><meta property="og:site_name"><meta name="application-name"><meta property="article:published_time"><meta name="publish-date"> or <meta name="date">--file <path>: Read URL from file (uses first line)--format <format>: Output format (default: bibtex)bibtex or bib: BibTeX formatcsl, json, or csl-json: CSL JSON format--no-wayback: Skip Wayback Machine submission (faster, but no archive)--output <file>: Write output to file (default: stdout)@online{smithexample2024,
author = {John Smith},
title = {Example Article Title},
url = {https://example.com/article},
urldate = {2024-03-15},
year = {2024}
}
[
{
"id": "smithexample2024",
"type": "webpage",
"title": "Example Article Title",
"author": [{"literal": "John Smith"}],
"URL": "https://example.com/article",
"accessed": {"date-parts": [[2024, 3, 15]]},
"archive-url": "https://web.archive.org/web/20240315123456/https://example.com/article"
}
]
npx tsx plugins/bib/scripts/cite-web.ts "https://example.com/article"
Output:
@online{example2024,
title = {Example Article Title},
url = {https://example.com/article},
urldate = {2024-03-15}
}
npx tsx plugins/bib/scripts/cite-web.ts "https://blog.example.com/post"
Output includes archive URL:
@online{example2024,
title = {Blog Post Title},
url = {https://blog.example.com/post},
urldate = {2024-03-15},
note = {Archived at https://web.archive.org/web/20240315123456/...}
}
npx tsx plugins/bib/scripts/cite-web.ts "https://docs.example.com" --format=csl
npx tsx plugins/bib/scripts/cite-web.ts "https://example.com" --no-wayback
npx tsx plugins/bib/scripts/cite-web.ts "https://example.com" --output=citations.bib
# Create file with URLs (one per line)
echo "https://example.com/article1" > urls.txt
# Cite each URL
while read url; do
npx tsx plugins/bib/scripts/cite-web.ts "$url" >> citations.bib
done < urls.txt
Citation keys are automatically generated from:
example.com β exampleJohn Smith β smithExamples:
https://blog.example.com/post by John Smith (2024) β smithexample2024https://example.com/article (no author, 2023) β example2023By default, the script submits URLs to the Internet Archive's Wayback Machine for preservation:
https://web.archive.org/save/<url>The archive URL is included in the citation:
note field or custom archiveurl/archivedate fieldsarchive-url fieldSkip archival with --no-wayback for faster execution when archiving isn't needed.
The script handles various error scenarios:
Errors are written to stderr, while citations are written to stdout (or file).
For complex pages or JavaScript-rendered content, consider:
--no-wayback to skip archival