regex - Fetching URL Based on InnerText C# -
i fetch url html
or string based on inner text value.
for example:
<a href="http://www.itsmywebaddress.com">my website</a>. <a href="http://www.everythingisforgood.com">good</a>.
here, need fetch url based on inner text of "my website" (which provide input).
can tell me , regex
code or using htmlagilitypack
how can this??
i have used following regex
method . however, fetching values inside "a" tag.
regex.match(str, @"<a [^>]*>(.*?)</a>").groups[1].value;
thanks in advance ...
htmlweb hw = new htmlweb(); htmlagilitypack.htmldocument doc = hw.load(url); var hrefs = doc.documentnode.selectnodes("//a[@href]") .where(link => link.innerhtml == str) .select(l=>l.attributes["href"].value).tolist();
Comments
Post a Comment