簡體   English   中英

登錄並通過http下載xml文件?

[英]Login and download an xml file over http?

需要從以下網址登錄並下載xml文件:

http://www.radionyhetene.net/download/nyheter/mp3/nyheter.xml

我已經知道如何使用WebClient和HttpWebRequest獲取和發布數據。但是對於上面的url,我根本無法理解該怎么做。

我嘗試對上述網址使用Live Http Header。 它顯示如下內容:

http://www.radionyhetene.net/download/nyheter/mp3/nyheter.xml
GET /download/nyheter/mp3/nyheter.xml HTTP/1.1
Host: www.radionyhetene.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115                Firefox/3.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Authorization: Basic aGF1Z2FsYW5kOjlmNm5kOGtmMw==

HTTP/1.1 200 OK
Date: Fri, 30 Mar 2012 16:09:35 GMT
Server: Apache/2.2.15 (Win32) PHP/5.3.2
Last-Modified: Fri, 30 Mar 2012 14:54:13 GMT
Etag: "4730000000053f1-194-4bc77038957a2"
Accept-Ranges: bytes
Content-Length: 404
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/xml

所以問題是如何將登錄信息傳遞給該URL? 請提供有關您的建議。 謝謝。

簡單,

WebClient web = new WebClient();
web.Credentials = new NetworkCredential("h.....", "9.......");
string s = web.DownloadString("http://www.radionyhetene.net/download/nyheter/mp3/nyheter.xml");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM