36

Is there an existing tool for generating BibTeX of a website using its URL? What I'm thinking is something like a web tool or a Python script that does this.

1

8 Answers 8

19

I'm using Zotero, a Firefox plugin, to collect and maintain my references. It has to possiblity to export to BibTeX and to generate an entry from a website. It supports several online formats for references, like Google Scholar or the IEEE Explorer website and can extract the data from them directly. For general websites it produces a generic entry.

For example it generated this entry from this very page:

@misc{_citing_????,
    title = {citing - Tool for generating a website's {BibTex} using the {URL?} - {TeX} - {LaTeX} - Stack Exchange},
    url = {http://tex.stackexchange.com/questions/32955/tool-for-generating-a-websites-bibtex-using-the-url},
    howpublished = {http://tex.stackexchange.com/questions/32955/tool-for-generating-a-websites-bibtex-using-the-url}
}
4
  • What package are you using "url" never works for me.
    – Magpie
    Commented Jan 26, 2013 at 21:42
  • @Magpie: I'm using hyperref which also uses url, but your bibliography style is what's important here, i.e. what code it does create from the url entry. Commented Jan 27, 2013 at 9:45
  • 2
    You may want to mention Zoterobib, which allows to access the same functionalities without having to install anything.
    – Clément
    Commented Aug 7, 2018 at 3:53
  • 1
    I just wish Zotero wouldn't make the BibTeX export such a hassle (save, export, to file, open file, copy BibTeX... ). I just want a browser plugin button that copies the BibTeX to my clipboard and saves the thing to my Zotero library
    – BlkPengu
    Commented Sep 7, 2020 at 9:38
31

A generic (reference manager and browser independent) solution:

  1. Create a new bookmark in the bookmark panel of your browser.

  2. Name it ("🌐 ➜ 📚" or whatever).

  3. URL: Insert this:

    javascript:"use strict";(function(){var _document$querySelect,_document$querySelect2,_document$querySelect3;function copyToClipboard(text){window.prompt("Copy to clipboard: Ctrl+C, Enter",text)}function jsDate2bibTex(date){var dd=date.getDate();var mm=date.getMonth()+1;var yyyy=date.getFullYear();if(dd<10){dd="0"+dd}if(mm<10){mm="0"+mm}return yyyy+"-"+mm+"-"+dd}function date2YearTex(date){var yyyy=date.getFullYear();return""+yyyy}var title=document.title;var url=document.URL;var author_tag=document.querySelector("[name=author]");var author=author_tag==null?"":author_tag.content;var today=new Date;var urldate=jsDate2bibTex(today);var publishedTime=(_document$querySelect=document.querySelector('meta[property="article:published_time"'))===null||_document$querySelect===void 0?void 0:_document$querySelect.getAttribute("content");var someTimeTag=(_document$querySelect2=document.querySelector("time[datetime]"))===null||_document$querySelect2===void 0?void 0:_document$querySelect2.getAttribute("datetime");var someTimeTagWithoutDatetime=(_document$querySelect3=document.querySelector("time"))===null||_document$querySelect3===void 0?void 0:_document$querySelect3.innerHTML;var lastModifiedTime=document.lastModified;var pageTime=new Date(publishedTime||someTimeTag||someTimeTagWithoutDatetime||lastModifiedTime);var date=jsDate2bibTex(pageTime);var year=date2YearTex(pageTime);var title_key=title.replace(/[^0-9a-z]/gi,"");var citationKey=title_key+"-"+date;var type="@Online";var filename=":./references/"+window.location.pathname.slice(1).replace(/\//g,"-")+".html:html";var title_tex=title.replace(/\u00e4/g,'\\"a').replace(/\u00c4/g,'\\"A').replace(/\u00f6/g,'\\"o').replace(/\u00d6/g,'\\"O').replace(/\u00fc/g,'\\"u').replace(/\u00dc/g,'\\"U').replace(/\u00DF/g,'\\"s');var bibTexEntry=type+" {"+citationKey+",\r  title = {"+title_tex+"},\r  date = {"+date+"},\r  year = {"+year+"},\r"+(author?"  author = {"+author+"},\r":"")+"  file = {"+filename+"},\r  url = {"+url+"},\r  urldate = {"+urldate+"}\r}";copyToClipboard(bibTexEntry)})();
    
  4. Load the page you want to cite.

  5. Click on the new bookmark button.

  6. Copy the selected text to clipboard and press [ENTER].

  7. Paste the BibLaTeX entry into

  • your .bib file.
  • JabRef: Just paste it into the open bibliography table.
  • Zotero: Go to 'file' -> 'import from clipboard'.

Sample output:

@Online {UsingBibTeXashortguide-2015-11-02,
 title = {Using BibTeX: a short guide},
 date = {2015-11-02},
 author = {Martin J. Osborne},
 file = {:./references/osborne-latex-BIBTEX.HTM.html:html},
 url = {https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM},
 urldate = {2018-03-17}
}

PS.: I hosted this on GitHub: https://github.com/dmstern/html2biblatex. Feel free to fork, star, contribute! :)


Update 2018: I optimized the code a bit. Could you guys please test it and report issues to https://github.com/dmstern/html2biblatex/issues? Thank you! :)

8
  • 1
    Welcome to TeX.SX! Would this work in any browser? Commented Apr 10, 2014 at 7:50
  • Hi, Torbjørn T.! I tested it with Google Chrome. Works fine for me. Sorry, no idea, if this works with other browsers.
    – Daniel
    Commented Apr 10, 2014 at 7:54
  • 1
    @Bruno: Sorry, there was a problem with some code escape characters. I created a git repository to file my script and updated my answer. Could you please try this version again? Thanks!
    – Daniel
    Commented Apr 10, 2014 at 9:37
  • 1
    @Daniel I started using your tool and I had few suggestions, so I started an issue in your repository, to be seen here: github.com/dmstern/html2biblatex/issues/2
    – FanaticD
    Commented May 12, 2016 at 11:56
  • 1
    Amazingly useful bookmark. Take my upvote. Commented Feb 4, 2020 at 16:19
8

This chrome extension I wrote sometime ago tries to address this. It creates a BibTeX entry from the active URL and copies it to clipboard automatically.There are three options to create a BibTeX entry from the active URL:

  • either press the extension button in the browser
  • right-click in the webpage and copy the bibtex to clipboard
  • assign a keyboard shortcut to the extension from Chrome menu to automatically copy the BibTeX entry of the active URL.

Example:

For http://developer.chrome.com/extensions/packaging.html we get:

@misc{Packa3:Online,
author = {},
title = {Packaging - Google Chrome},
howpublished = {\url{https://developer.chrome.com/extensions/packaging}},
month = {},
year = {},
note = {(Accessed on 06/07/2014)}
}

1
  • @clement thanks for the feedback. I could add some option to select the format. I was using online before, but for my personal needs misc was better. It should be easy to have it as an option though. Since I am not really an experienced TeX user, what are the candidate formats you would recommend (fields etc.)?
    – nettrino
    Commented Feb 20, 2016 at 0:48
3

This site allows you to create a citation from a URL and then export it as a bibtex reference:

https://www.citethisforme.com/apa

1
  • Unfortunately, this service does not offer bibtex export anymore…
    – Clément
    Commented Apr 20, 2020 at 4:58
2

Also, https://www.refme.com/ allows you to generate a list of references online from urls and export it to a BibTex file when you are done.

1
1

(Moved here from duplicate)

One can use a browser extension:

Some for Firefox

CurrentPageToBibTeX

  • parses HTML meta tags
  • doesn't always work
  • fast setup

Cite This!

  • couldn't get it to work, but has many users

BibItNow!

  • lots of options
  • seems to work well
  • urldate, @online have to be enabled
  • best for Firefox, in my opinion

A few for Chrome

BibTeX entry from URL

  • copies to clipboard
  • not many, but useful options (e.g. for date format and @online)
  • works best, in my opinion (in 2021)

BibItNow!

  • Specs: same as Firefox
  • I did not test it

In the end, the entries will most likely need manual editing. E.g. author or publication date are reliably captured only when tagged in HTML.

0

I've created the simple URL to BibTeX webapp which generates basic BibTeX entry based on URL:

app

The source code is available here.

0

getbibtex can easily do the job. But it is not as detailed as bibme does. However the information is inconsistent from bibme.org. you might manually edit/correct some.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .