Exporting open tabs to Opasnet

From Opasnet
Jump to: navigation, search


Question

How to export open tabs to Opasnet?

Answer

Often when you have performed a search about a topic, you have a lot of tabs open, and you'd like to have an easy way to export all those to an Opasnet page as links. This is how to do it.

  1. Organise tabs on a web browser (Firefox) so that all that you want to save are on one window.
  2. On that browser window, right-click a tab and "Select all tabs".
  3. Right-click again "Bookmark tabs". Save them in a temporary folder.
  4. Go to Bookmarks >> Import and Backup >> Export Bookmarks to HTML... and save the bookmarks to ~/bookmarks.html (note that ALL bookmarks will be exported, not only the active folder)
  5. Run the following code in R.
  6. Open temp.csv from your home folder and copy-paste the links you want to Opasnet
  7. Remove the temporary folder from bookmarks and the two temporary files created.
library(xml2)
library(rvest)
tst <- html_nodes(read_html("~/bookmarks.html", options="HUGE"), css="a")
out <- data.frame(
  ref=html_attr(tst, name="href"),
  name=html_text(tst)
)
out$out <- paste0("* [", out$ref, " ", out$name, "]")
write_csv(out[3], "~/temp.csv")