I am trying to parse the HTML from Hotpads and am confused on how to get extract the script tag and map part of it into a Json object.By using HTMLAgilityPack I have loaded an example url and it breaks where it looks for that tag. I plan on deserializing it after
Main method
private static void ParseSite()
{
var url = "https://hotpads.com/308-s-9th-dr-ponte-vedra-beach-fl-32082-syw3eh/building";
var web = new HtmlWeb();
var doc = web.Load(url);
var link = doc.DocumentNode.SelectSingleNode("//a[contains(.,'window.__PRELOADED_STATE__')]");
if (link != null)
{
Console.WriteLine(link.InnerText);
}
Console.ReadLine();
}
Script tag:
<script>
window.__PRELOADED_STATE__ = {{SOME JSON HERE}}
<script>
Model:
public class Contact
{
public string DATA_MODEL { get; set; }
public string companyName { get; set; }
public string contactName { get; set; }
public string contactPhone { get; set; }
}