3
我想進行映射的現實世界的總統。readHTMLTables - 檢索國家名稱和相關的政府首腦文章的網址
爲此,我想從維基百科中颳去每個總統的圖像。
來自維基頁面的第一步是獲取數據: http://en.wikipedia.org/wiki/List_of_current_heads_of_state_and_government
我有麻煩的國名和總統的網頁網址,因爲該表有rowspans。
目前,我的代碼看起來像下面,但它是因爲該行跨越的不正常..
library(XML)
u = "http://en.wikipedia.org/wiki/List_of_current_heads_of_state_and_government"
doc = htmlParse(u)
tb = getNodeSet(doc, "//table")[[3]]
stateNames <- readHTMLTable(tb)$State
presidentUrls <- xpathSApply(tb, "//table/tr/td[2]/a[2]/@href")
任何想法,歡迎!
墊