I'm trying to find a way to copy-paste the title and the abstract from a PubMed page.
I started using
browseURL("https://pubmed.ncbi.nlm.nih.gov/19592249") ## final numbers are the PMID
now I can't find a way to obtain the title and the abstract in a txt way. I have to do it for multiple PMID so I need to automatize it. It can be useful also just copying everything is on that page and after I can take only what I need. Is it possible to do that? thanks!
I suppose what you're trying to do is scrape PubMed for articles of interest?
Here's one way to do this using the
rvestpackage:The code should be fairly self-explanatory. (I've not added the contents of
dfhere for brevity.) The functiongetpubmeddoes no error-handling or anything of that sort, but it is a start. By supplying a vector of URLs to thedo.call("rbind", lapply(urls, getpubmed))construct, you can get back adata.frameconsisting of the PubMed ID, title, and abstract as columns.Another option would be to explore the
easyPubMedpackage.