c# - XmlReader Error in reading RSS Feed -


i trying read rss feed http://backend.deviantart.com/rss.xml?q=gallery:duster132/23316533&type=deviation following code:

        //different rss links         string deviant_rsslink = @"http://backend.deviantart.com/rss.xml?q=gallery:duster132/23316533&type=deviation";         string blogspot_rsslink = @"http://fightpunch.blogspot.com/feeds/posts/default";          //reading links         xmlreader reader = xmlreader.create(deviant_rsslink); //line error occurs         syndicationfeed feed = syndicationfeed.load(reader);         reader.close();         foreach (syndicationitem item in feed.items)         {             string subject = item.title.text;             console.writeline("subjext is: " + subject + "\n");         } 

...and error:

"the underlying connection closed: connection closed unexpectedly." 

at first thought deviantart might blocking ip tried different computers differing ips error persists, seems not issue. make things more difficult track, code works no error @ http://fightpunch.blogspot.com/feeds/posts/default.

what should try fix this?

you site requires user-agent header set

below code should work..

string rss = null; using (var wc = new webclient()) {     wc.headers["user-agent"] = "so/1.0";     rss = wc.downloadstring(deviant_rsslink); } xmlreader reader = xmlreader.create(new stringreader(rss)); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -