抓取 Github 提交作者元素
Scraping Github commit author element
任何 html 能提取此 link 上的元素的文本的人:https://github.com/tidyverse/ggplot2
所需的元素文本是
我目前正在 r 中使用 rvest。已尝试 xpath、css 等,但无法提取用户名。很高兴采用包含名称的 link 并在需要时使用正则表达式清理文本。
非常感谢任何帮助。
library(rvest)
read_html("https://github.com/tidyverse/ggplot2") %>%
html_nodes(".user-mention") %>%
html_text()
# [1] "thomasp85"
但如果你想从多个仓库中获取信息,你可能要考虑使用官方 GitHub REST API and/or this lightweight R package client。
任何 html 能提取此 link 上的元素的文本的人:https://github.com/tidyverse/ggplot2
所需的元素文本是
我目前正在 r 中使用 rvest。已尝试 xpath、css 等,但无法提取用户名。很高兴采用包含名称的 link 并在需要时使用正则表达式清理文本。
非常感谢任何帮助。
library(rvest)
read_html("https://github.com/tidyverse/ggplot2") %>%
html_nodes(".user-mention") %>%
html_text()
# [1] "thomasp85"
但如果你想从多个仓库中获取信息,你可能要考虑使用官方 GitHub REST API and/or this lightweight R package client。