I was wondering if someone could help me, im looking to make a program to check if an item is in stock on a website, but im not too sure about how to go about it. Any pointers?

Dani AI

Generated

Two practical routes were already hinted at by and : get structured data from the site owner if possible, or retrieve the page yourself and look for the stock indicator. Below are concise, actionable VB.NET notes that build on those paths and are tailored for an ASP.NET app.

If no official API exists, fetch the page and parse it with a sturdy HTML parser rather than fragile string searches. Example (VB.NET, async) using HttpClient and HtmlAgilityPack — adjust the XPath or text tests to match the target page structure:

Imports System.Net.Http
Imports HtmlAgilityPack

Public Async Function IsInStockAsync(url As String) As Task(Of Boolean)
    Using client As New HttpClient()
        client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (compatible; ItemChecker/1.0)")
        Dim html As String = Await client.GetStringAsync(url)
        Dim doc As New HtmlDocument()
        doc.LoadHtml(html)
        Dim node = doc.DocumentNode.SelectSingleNode("//div[contains(@class,'stock') or contains(@id,'stock')]")
        Return (node IsNot Nothing AndAlso node.InnerText.IndexOf("in stock", StringComparison.OrdinalIgnoreCase) >= 0)
    End Using
End Function

Production tips and cautions: run checks as a scheduled background job or serverless function, throttle requests and use exponential backoff, cache results and watch for layout changes (log diffs). For JavaScript-rendered pages use a headless browser (Playwright/Selenium). Always respect robots.txt and the site terms of service and avoid bypassing CAPTCHAs or other protections. Library references: and HttpClient docs.

Recommended Answers

All 2 Replies

Are you talking about checking in the database (you have access to it) or scraping an HTML page to see what is on it?
If scraping, you need to use the WebRequest class to retrieve the contents of a webpage and then parse through it looking for what you need. You can find plenty of screen scraping tutorials online.

Sounds to me like you need a web service, time to check with the website owner whether one exists or if one can be created. Assuming there is one, the owner of the website should have documentation on how to utilise it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.