rss를 다운로드하려면 WebClient가 필요하지 않습니다.
XDocument wp = XDocument.Load("http://wordpress.org/news/feed/");
XNamespace ns = XNamespace.Get("http://purl.org/rss/1.0/modules/content/");
foreach (var content in wp.Descendants(ns + "encoded"))
{
Console.WriteLine(System.Net.WebUtility.HtmlDecode(content.Value)+"\n\n");
}
EDIT
문제는 압축과 관련된다. 클라이언트가 압축을 지원하지 않으면 서버는 내용을 보내지 않습니다.
WebClient web = new WebClient();
web.Headers["Accept-Encoding"] = "gzip,deflate,sdch";
var zip = new System.IO.Compression.GZipStream(
web.OpenRead("http://www.whiskymag.fr/feed/?post_type=sortir"),
System.IO.Compression.CompressionMode.Decompress);
string rss = new StreamReader(zip, Encoding.UTF8).ReadToEnd();
내용 : 인코딩 된 상태가 여전히 여기에 없습니다. – Gregoire
@Gregoire, 위의 예제가 작동합니다. 게시하기 전에 시도했습니다. 다른 URL을 사용합니까? –
URL을 내가 시도 : http://www.whiskymag.fr/feed/?post_type=sortir – Gregoire