In Internet Explorer, F12 gives access to two tabs: DOM Explorer and DEBUGGER.
Both of these tabs have different contents but I do not yet know what their distinction is.
I want to capture the DOM Explorer data, not the DEBUGGER information of a webpage.
When I use either of the following two pieces of code I capture the information found in the DEBUGGER, my question is: How do I capture the DOM EXPLORER data so that I can run REGEX?
CODE 1:
string urlAddress = "https://www.goodgaragescheme.com/pages/map.aspx?loc=CO70AN";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = null;
if (response.CharacterSet == null)
{
readStream = new StreamReader(receiveStream);
}
else
{
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
}
string data = readStream.ReadToEnd();
System.IO.File.WriteAllText(@"FILENAME.txt", data);
response.Close();
readStream.Close();
}
CODE 2:
using (var client = new System.Net.WebClient())
{
var content = client.DownloadString("https://www.goodgaragescheme.com/pages/map.aspx?loc=CO70AN");
System.IO.File.WriteAllText(@"FILENAME.txt", content);
}
Here is the answer:
SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
IE.Visible = false;
IE.Navigate(@"https://www.goodgaragescheme.com/pages/map.aspx?loc=CO70AN");
System.Threading.Thread.Sleep(5000);
mshtml.IHTMLDocument2 htmlDoc = IE.Document as mshtml.IHTMLDocument2;
string content = htmlDoc.body.outerHTML;
System.IO.File.WriteAllText(@"FILENAME.txt", content);
System.Console.WriteLine("done");
System.Console.ReadKey();
Persistence FTW.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.