问题描述
所以我有很多类似的链接地址:端口/ BLA-BLA / BLA-BLA /文件/ blabla234times /有些服务器(如VLC)我怎样才能得到所有的链接(其中列表)avaliable从服务器创建(摘要服务器从我的C#PROGRAMM在Windows上工作)?
So I have lots of links like address:port/Bla-bla/bla-bla/file/blabla234times/ created by some server (like VLC) how can I get all links (list of them) avaliable from server (abstract server working on windows) from my C# programm?
因此,如何使自己的服务器上所有现有文件和文件夹列表,或URL。我们有联系地址和端口。 (无HTML页面什么 - 只要服务器联系地址)
So how to get a list or URLs of ALL existing files and folders on server. We have adress and port. (no HTML pages nothing - just server adress)
我要扫描服务器以检索其链接
I want to scan a server to retrive its links
推荐答案
如果您有兴趣从Web服务器可以使用的来解析这个文件:
If you are interested in extracting anchor links from HTML document sent by a web server you could use Html Agility Pack to parse this document:
class Program
{
static void Main()
{
var document = new HtmlDocument();
using (var client = new WebClient())
using (var reader = new StringReader(client.DownloadString("http://www.google.com")))
{
document.Load(reader);
}
var anchors = document.DocumentNode.SelectNodes("//a");
foreach (var anchor in anchors)
{
Console.WriteLine(anchor.Attributes["href"].Value);
}
}
}
这篇关于如何获得的所有环节,从服务器avaliable在一些端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!