我正在尝试抓取并解析以下RSS提要http://www.huffingtonpost.com/rss/liveblog/liveblog-1213.xml我已查看有关R和XML的其他查询,但无法取得任何进展在我的问题上.每个条目的xml代码
<item>
<title><![CDATA[Five Rockets Intercepted By Iron Drone Systems Over Be'er Sheva]]></title>
<link>http://www.huffingtonpost.co.uk/2012/11/15/tel-aviv-gaza-rocket_n_2138159.html#2_five-rockets-intercepted-by-iron-drone-systems-over-beer-sheva</link>
<description><![CDATA[<a href="http://www.haaretz.com/news/diplomacy-defense/live-blog-rockets-strike-tel-aviv-area-three-israelis-killed-in-attack-on-south-1.477960" target="_hplink">Haaretz reports</a> that five more rockets intercepted by Iron Dome systems over Be'er Sheva. In total, there have been 274 rockets fired and 105 intercepted. The IDF has attacked 250 targets in Gaza.]]></description>
<guid>http://www.huffingtonpost.co.uk/2012/11/15/tel-aviv-gaza-rocket_n_2138159.html#2_five-rockets-intercepted-by-iron-drone-systems-over-beer-sheva</guid>
<pubDate>2012-11-15T12:56:09-05:00</pubDate>
<source url="http://huffingtonpost.com/rss/liveblog/liveblog-1213.xml">Huffingtonpost.com</source>
</item>
Run Code Online (Sandbox Code Playgroud)
对于每个条目/帖子,我想记录"日期"(pubDate),"标题"(标题),"描述"(全文清除).我曾尝试在R中使用xml包,但承认我是一个新手(很少有没有使用XML的经验,但有些R经验).我正在处理的代码,无处可去的是:
library(XML)
xml.url <- "http://www.huffingtonpost.com/rss/liveblog/liveblog-1213.xml"
# Use the xmlTreePares-function to parse xml file directly from the web
xmlfile <- xmlTreeParse(xml.url)
# Use the xmlRoot-function to …Run Code Online (Sandbox Code Playgroud) 在之前的一个问题中,我询问是否使用R中的twitteR软件包从Haaretz Twitter订阅源(@haaretzcom)下载大量Twitter关注者(及其位置,创建日期,关注者数量等)(请参阅工作率在R)中使用twitteR包提取大量用户信息的限制.Twitter提要有超过90,000个关注者,我可以使用下面的代码下载完整的关注者列表没问题.
require(twitteR)
require(ROAuth)
#Loading the Twitter OAuthorization
load("~/Dropbox/Twitter/my_oauth")
#Confirming the OAuth
registerTwitterOAuth(my_oauth)
# opening list to download
haaretz_followers<-getUser("haaretzcom")$getFollowerIDs(retryOnRateLimit=9999999)
for (follower in haaretz_followers){
Sys.sleep(5)
haaretz_followers_info<-lookupUsers(haaretz_followers)
haaretz_followers_full<-twListToDF(haaretz_followers_info)
#Export data to csv
write.table(haaretz_followers_full, file = "haaretz_twitter_followers.csv", sep=",")
}
Run Code Online (Sandbox Code Playgroud)
该代码用于提取许多用户.但是,每当我遇到某个用户时,我都会收到以下错误:
Error in twFromJSON(out) :
RMate stopped at line 51
Error: Malformed response from server, was not JSON.
RMate stopped at line 51
The most likely cause of this error is Twitter returning a character which
can't be properly parsed …Run Code Online (Sandbox Code Playgroud)