English 中文(简体)
传真机包——信用套
原标题:HTML Agility Pack - Filter Href Value Results

I m在网络报废器上工作。 以下案文显示了这一问题结束时给出的法典的结果,它从一页中得出了所有作者的价值观。

我只想获得包含<代码>docid=的数值。

指数.php?pageid=a45475a11ec72b843d74959b60fd7bd64556e8988583f

页: 1

摘要_of_documents.php

指数.php?pageid=a45475a11ec72b843d74959b60fd7bd64579b861c1d7b

页: 1

指数.php?pageid=a45475a11ec72b843d74959b60fd7bd64579e0509c7f0&apform=judiciary

decisions.php?doctype=Decisions / Signed Resolutions&docid=1263778435388003271页: 1sam

decisions.php?doctype=Decisions / Signed Resolutions&docid=12637789021669321156页: 1sam

?doctype=Decisions / Signed Resolutions&year=1986&month=January页: 1head

?doctype=Decisions / Signed Resolutions&year=1986&month=February页: 1head

该法典:

        string url = urlTextBox.Text;
        string sourceCode = Extractor.getSourceCode(url);

        HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
        doc.LoadHtml(sourceCode);
        List<string> links = new List<string>();

        if (links != null)
        {
            foreach (HtmlAgilityPack.HtmlNode nd in doc.DocumentNode.SelectNodes("//a[@href]"))
            {
                links.Add(nd.Attributes["href"].Value);
            }
        }
        else
        {
            MessageBox.Show("No Links Found");
        }

        if (links != null)
        {
            foreach (string str in links)
            {
                richTextBox9.Text += str + "
";
            }
        }
        else
        {
            MessageBox.Show("No Link Values Found");
        }

我如何能够这样做?

最佳回答

为什么不只取代:

links.Add(nd.Attributes["href"].Value);

为此:

if (nd.Attributes["href"].Value.Contains("docid="))
    links.Add(nd.Attributes["href"].Value);
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签