我真正想要实现的是从 this address 获取链接,每个壁纸的链接。例如,此链接:https://www.flickr.com/photos/visualechos/14925188846/in/album-72157622467976256/ .
这是我尝试过的一些方法,但由于某些原因,所有壁纸链接都没有使用这些方法:
using (WebClient client = new WebClient())
{
string code = client.DownloadString("http://www.flickr.com/photos/visualechos/sets/72157622467976256");
}
-
using (WebClient client = new WebClient())
{
client.DownloadFile("http://www.flickr.com/photos/visualechos/sets/72157622467976256", @"C:\code.html");
}
-
// Using HtmlAgilityPack
public void GetLinks(string url)
{
HtmlWeb hw = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = hw.Load(url);
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
LINK.Add(link.GetAttributeValue("href", "link not found"));
}
}
private void btnStoreLinks_Click(object sender, EventArgs e)
{
GetLinks("https://www.flickr.com/photos/visualechos/sets/72157622467976256");
}
最佳答案
您可以尝试使用 flickr-API,而不是抓取网站,记录在此处:https://www.flickr.com/services/api/misc.urls.html
您也应该在他们的网站上阅读此主题:https://www.flickr.com/services/api/auth.oauth.html
之后就相当简单了,您为新的客户端密码发出第一个 OAuth 请求 - 然后将请求发送到 API。 WebRequest
是您正在搜索的图书馆。
关于c# - 从网站 URL 获取链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38554890/