前提・実現したいこと
Rでスクレイピングをしております。
対象サイト
https://www.coingecko.com/en/ico?show_by=ended
テーブル内にいくつか、URLリンクがあり、各行単位にこのURLのリンクを取得し、
データフレームにしたいです。
以下のように実施すると、テーブル内のテキストは取れますが、URLのリンクは取れません。
coin_ico_url <- "https://www.coingecko.com/ja/ico?show_by=ended" coin_ico <- read_html(coin_ico_url, encoding = "UTF-8") %>% html_nodes(xpath= '//*[contains(concat( " ", @class, " " ), concat( " ", "table-scrollable", " " ))] ') %>% html_table()
一方、以下のように実行するとURLは取れますが、テキストの情報とは泣き別れになります。
coin_ico_url <- "https://www.coingecko.com/ja/ico?show_by=ended" coin_ico_href <- read_html(coin_ico_url, encoding = "UTF-8") %>% html_nodes(xpath= '//*[contains(concat( " ", @class, " " ), concat( " ", "table-scrollable", " " ))]') %>% html_nodes(xpath = "//a[starts-with(@href, 'http')]") %>% html_attr("href")
うまく、行単位にURLを取得する方法はないでしょうか?
あなたの回答
tips
プレビュー