Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using mshtml;
- class Scraper
- {
- static async Task Main()
- {
- //..
- {
- //...
- // Create an HTMLDocument and cast it to IHTMLDocument2
- var htmlDoc = new HTMLDocument();
- var ihtmlDoc = (IHTMLDocument2)htmlDoc;
- // Open the document and write the HTML content
- ihtmlDoc.open();
- ihtmlDoc.write(htmlContent);
- ihtmlDoc.close();
- // Access the document's DOM
- var allElements = ihtmlDoc.all;
- // Find the element with class "stock"
- foreach (IHTMLElement element in allElements)
- {
- if (element.className == "stock")
- {
- // Extract the stock amount text
- string stockAmount = element.innerText;
- Console.WriteLine("Stock Amount: " + stockAmount);
- }
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement