简体   繁体   中英

Access Google Chrome Inspect Element with .NET

I have a problem and I can't quite find the solution. My task is to access the text provided from Google Chrome Inspect Element. For example - if I would be given a webpage "http://stackoverflow.com" then I should get the text located in Inspect Element (right click->Inspect element). Does anyone know how to do this in .NET?

PS I have an alternative solution, but I want to maximize the effectiveness of this task. My current solution is making .NET to open Google Chrome programmatically and then with keyboard shortcuts access the Inspect Element text. But I would like to do this in background(the programm does everything while I'm doing some other stuff).

Do you want to download the page source? Because that is basically what inspect element does. Please tell me if i'm wrong.

string remoteUri = "http://www.contoso.com/library/homepage/images/";
            string fileName = "ms-banner.gif", myStringWebResource = null;
            // Create a new WebClient instance.
            WebClient myWebClient = new WebClient();
            // Concatenate the domain with the Web resource filename.
            myStringWebResource = remoteUri + fileName;
            Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
            // Download the Web resource and save it into the current filesystem folder.
            myWebClient.DownloadFile(myStringWebResource,fileName);     
            Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
            Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);

Not my code, it's from http://msdn.microsoft.com/en-us/library/ez801hhe.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2 .

Then you can use whatever function to read the file and use the source.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM