+
95
-

c#如何获取网页里所有的链接完整url地址?

请问c#如何获取网页里所有的链接完整url地址?

网友回复

+
15
-
using System;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;

namespace HelloWorldApplication
{
    class HelloWorld
    {
        static void Main(string[] args) {
            System.Net.WebClient client = new WebClient();
            byte[] page = client.DownloadData("http://www.bfw.wiki");
...

点击查看剩余70%

+
15
-

这样也可以

using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace HelloWorldApplication
{
    class HelloWorld
    {

        public static string GetHtml(string url) {
            string res = "";
            WebClient client = new WebClient();
            Stream stream = client.OpenRead(url);
            StreamReader sr = new StreamReader(stream, Encoding.Default);
       ...

点击查看剩余70%

我知道答案,我要回答