如何编写脚本以从此站点下载文件.是否可以通过URL提供登录名和密码?
http://feeds.itunes.apple.com/feeds/epf/
我会像这样格式化网址吗?
WebClient Client = new WebClient();
Client.DownloadFile("http://feeds.itunes.apple.com/feeds/epf/v3/full/current/itunes20110511.tbz.md5?username=myusername&password=mypassword", @"C:\folder\file.md5");
Run Code Online (Sandbox Code Playgroud)
Dre*_*rsh 16
是的,只需使用用户名/密码将WebClient's
Credentials
属性设置为NetworkCredentials
实例即可.例如:
Client.Credentials = new System.Net.NetworkCredential("john", "password1234!");
Run Code Online (Sandbox Code Playgroud)
And*_*ykh 15
使用WebClient.Credentials属性为网站提供凭据:
using (WebClient client = new WebClient()) {
client.Credentials = new NetworkCredential(username, password);
client.DownloadFile("http://feeds.itunes.apple.com/feeds/epf/v3/full/current/itunes20110511.tbz.md5", @"C:\folder\file.md5");
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
26986 次 |
最近记录: |