提取網頁中的超連結 C

2021-03-31 08:56:59 字數 956 閱讀 7597

using system;

using system.xml;

using system.text;

using system.***;

using system.io;

using system.collections;

using system.text.regularexpressions;

console.writeline("正在獲取頁面**,請稍侯..."); 

strcode = getpagesource(strurl);

console.writeline("正在提取超連結,請稍侯..."); 

allinks = gethyperlinks(strcode);

console.writeline("正在寫入檔案,請稍侯..."); 

writetoxml(strurl,allinks);

}// 獲取指定網頁的html**

static string getpagesource(string url)

// 提取html**中的**

static arraylist gethyperlinks(string htmlcode)

}

if(!rep) al.add(strnew);

}al.sort();

return al;

}// 把**寫入xml檔案

static void writetoxml(string strurl, arraylist alhyperlinks)

writer.writeendelement();

writer.writeendelement();

writer.flush();

writer.close();

}// 獲取**的網域名稱字尾

static string getdomain(string strurl)

}

提取網頁中的超連結

using system using system.xml using system.text using system.net using system.io using system.collections using system.text.regularexpressions console...

提取網頁中的超連結

using system using system.xml using system.text using system.net using system.io using system.collections using system.text.regularexpressions console...

提取網頁中的超連結

using system using system.xml using system.text using system.net using system.io using system.collections using system.text.regularexpressions console...