Reputation: 263
I'm trying to extract link from href.<a class="p_l" href="" id="0" target="_blank">
This is what is visible in page view source but when i inspect using firebug, href will contain http://home.website.com/preview/preview?uname=3eadsf132sdas
. I tried using htmlagilitypack but href is returning null. How to extract the link in href.
Upvotes: 0
Views: 790
Reputation: 1326
You could try something different, like getting the html content using the WebRequest class (see here how).
If the href doesn't contain any link it could mean that it is being populated using Javascript or some other programming language to add the dynamic content. If you have access to the scripts then you might have a small chance to get the links, but don't think so.
Upvotes: 1
Reputation: 11191
If you have not tried this way than please try it this way
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags=true;
htmlDoc.Load(filePath);
foreach(HtmlNode link in htmlDoc.DocumentElement.SelectNodes("//a[@href"])
{
if(link != null)
{
if(link["href"] != null)
{
HtmlAttribute att = link["href"];
var url = att.Value;
}
}
Upvotes: 1