简体   繁体   English

ASP.NET 获取网站的所有页面

[英]ASP.NET Get all pages of website

I want to parse some websites and get list of all pages on current domain, like a:我想解析一些网站并获取当前域上所有页面的列表,例如:

sample.com/样品.com/

sample.com/page1/ sample.com/page1/

sample.com/page2.html sample.com/page2.html

But I can't find samples, how to build this sitemap or tree using C# and ASP.NET但是我找不到示例,如何使用 C# 和 ASP.NET 构建此站点地图或树

I found only one example: http://www.codeproject.com/Articles/13486/A-Simple-Crawler-Using-C-Sockets我只找到了一个例子: http : //www.codeproject.com/Articles/13486/A-Simple-Crawler-Using-C-Sockets

But I can't understand, how author use it但我不明白,作者如何使用它

if(Directory.Exists(strUri) == true) { //some code DirectoryInfo dir = new DirectoryInfo(folderName); FileInfo[] fia = dir.GetFiles("*.txt"); }

When I use this code, result in if is always false .当我使用此代码时,导致if始终为false When I use only当我只使用

GetFiles function GetFiles函数

I have Exception:我有例外:

URI formats are not supported不支持 URI 格式

Who have any ideas?谁有任何想法?

remember that on a Web ambient, you cant read files that way, you need to use请记住,在 Web 环境中,您无法以这种方式读取文件,您需要使用

Server.MapPath(url)

to get the physical address to the files, then you can do the loop you are using.获取文件的物理地址,然后您可以执行您正在使用的循环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM