-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpubs-rss.qmd
53 lines (42 loc) · 1.01 KB
/
pubs-rss.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
title: "PubMed Article Replication"
output:
quarto::pdf_document:
latex_engine: xelatex
---
```{r setup, include=FALSE}
library(rvest)
library(quarto)
library(tidyverse)
```
```{r}
# Fetch the webpage content
url <- "https://pubmed.ncbi.nlm.nih.gov/36460922/"
page <- read_html(url)
# Extract article title
title <- page %>%
html_nodes(".heading-title") %>%
html_text() %>%
str_trim()
# Extract article abstract
abstract <- page %>%
html_nodes(".abstract-content") %>%
html_text() %>%
str_trim()
# Extract article authors
authors <- page %>%
html_nodes(".authors-list") %>%
html_text() %>%
str_trim()
# Extract article journal and publication date
journal_date <- page %>%
html_nodes(".journal-actions") %>%
html_text() %>%
str_trim()
# Print the extracted content
cat(paste("### Title:\n\n", title, "\n\n"))
cat(paste("### Authors:\n\n", authors, "\n\n"))
cat(paste("### Journal and Publication Date:\n\n", journal_date, "\n\n"))
cat(paste("### Abstract:\n\n", abstract, "\n\n"))
```
```{r}