Advertisement
dereksir

Untitled

Oct 31st, 2023 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using mshtml;
  2.  
  3. class Scraper
  4. {
  5.     static async Task Main()
  6.     {
  7.         //..
  8.         {
  9.             //...
  10.  
  11.             // Create an HTMLDocument and cast it to IHTMLDocument2
  12.             var htmlDoc = new HTMLDocument();
  13.             var ihtmlDoc = (IHTMLDocument2)htmlDoc;
  14.  
  15.             // Open the document and write the HTML content
  16.             ihtmlDoc.open();
  17.             ihtmlDoc.write(htmlContent);
  18.             ihtmlDoc.close();
  19.  
  20.             // Access the document's DOM
  21.              var allElements = ihtmlDoc.all;
  22.  
  23.             // Find the element with class "stock"
  24.             foreach (IHTMLElement element in allElements)
  25.             {
  26.                 if (element.className == "stock")
  27.                     {
  28.                         // Extract the stock amount text
  29.                         string stockAmount = element.innerText;
  30.                         Console.WriteLine("Stock Amount: " + stockAmount);
  31.                     }
  32.             {
  33.            
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement