0
私はUN FAOのウェブサイト(http://www.fao.org/countryprofiles/en/)からデータセットを構築しようとしています。 このページには、国へのリンクが含まれています。 このリンクをクリックすると、その国のニュースが含まれている特定の国のページが表示されます。 アイデアは、データセットに含まれるようになります:R Webscrapingデータセット
Country name
Country url (e.g. <http://www.fao.org/countryprofiles/index/en/?iso3=AFG>)
News url (e.g. <http://www.fao.org/afghanistan/news/detail-events/en/c/1045264/>)
News title (e.g. World Food Day 2017 Celebrations in Afghanistan)
News date (e.g. 17/11/2017)
はまだ、私が行っている次
## Import web page
FAO_Countries <- read_html("http://www.fao.org/countryprofiles/en/")
## Import the urls I am interested in with 'selectorgadget'
FAO_Countries_urls <- FAO_Countries %>%
html_nodes(".linkcountry") %>%
html_attr("href")
## Import the links I am interested in with 'selectorgadget'
FAO_Countries_links <- FAO_Countries %>%
html_nodes(".linkcountry") %>%
html_text()
## I create a dataframe with two previous objects
FAO_Countries_data <- data.frame(FAO_Countries_links=FAO_Countries_links,
FAO_Countries_urls = FAO_Countries_urls, stringsAsFactors = FALSE)
どのように進めるべき?ここで
あなたがa)は、あなたがロードされているパッケージの一覧を表示する必要があり、およびb)あなたが持っているかの困難を示しています。 –
1.パッケージは、次のとおりです。 rvest、 stringr、 tidyr、 data.table、 plyr、 XML2。 2.ニュースとニュースの日付を取得できません – Ileeo