Advertisement
dereksir

Untitled

Oct 31st, 2023 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using Majestic12;
  2.  
  3. class Scraper
  4. {
  5.     static async Task Main()
  6.     {
  7.         //..
  8.         {
  9.             //...
  10.  
  11.             // Create an HTML parser instance
  12.             HTMLparser oP = new HTMLparser();
  13.  
  14.             // Load HTML content
  15.             oP.Init(htmlContent);
  16.  
  17.             // Find the stock amount element by its class
  18.             HTMLchunk oChunk = null;
  19.             while ((oChunk = oP.ParseNext()) != null)
  20.             {
  21.                 if (oChunk.oType == HTMLchunkType.Text)
  22.                 {
  23.                     if (oChunk.oHTML.Contains("in stock"))
  24.                     {
  25.                         string stockAmount = oChunk.oHTML;
  26.                         Console.WriteLine("Stock Amount: " + stockAmount);
  27.                         break;
  28.                     }
  29.                 }
  30.  
  31.             }
  32.  
  33.         }
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement