none
Issue when iam trying to get a value from a class in webpage sometimes NULL ? RRS feed

  • Question

  • hello every one,

    i have a web page and I'm was getting the values for the classes normal suddenly i get null

    after i restart my application sometimes i get the values and sometimes no

    what is the problem?

    this the class for the web page

    <tr data-block-id="150556201_195357302_0_42_0" class="hprt-table-cheapest-block hprt-table-cheapest-block-fix js-hprt-table-cheapest-block" data-et-view="">
    
    <div class="bui-price-display__value prco-ltr-center-align-helper prco-font16-helper" aria-hidden="true">
    AED&nbsp;265
    </div>

    and this is my code

     If WebBrowser1.IsBusy = False AndAlso WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then

    For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("tr") If Element.GetAttribute("className") = "" And Element.OuterHtml.Contains("150556201_195357302_0_42_0") Then For Each Element1 As HtmlElement In Element.GetElementsByTagName("div") If Element1.GetAttribute("className") = "bui-price-display__value prco-ltr-center-align-helper prco-font16-helper" Then Dim Variable1 As String = Element1.InnerText PricesDetails.stkr.Text = Element1.InnerText PricesDetails.stkr.Text = PricesDetails.stkr.Text.Replace("AED", "") End If Next End If Next

    End if




    Saturday, October 26, 2019 12:11 PM

All replies

  • You may or may not be doing this, if not please try and run your code in DocumentCompleted event. Or if done in a Button Click event, disable the button at form start and then enable it in DocumentCompleted event.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Saturday, October 26, 2019 1:33 PM
  • Thank you for your answer,

    i already try all of those ways but still have the same issue

    Saturday, October 26, 2019 1:38 PM
  • Thank you for your answer,

    i already try all of those ways but still have the same issue

    Then you need to indicate everything you have tried so we don't reply with things you tried so far.

    One last thing, if the code works sometimes and not other times when it fails open the page in the browser dev tools and inspect elements to see if they exists as it's possible with web pages to change be it a possibility or not here it can be worth checking out. I give this to you from myself as a web developer.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, October 26, 2019 1:57 PM
  • hello,

    Today i tried this code

     Private Sub WebBrowser2_ProgressChanged(sender As Object, e As WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
            Txtcurrentprogrees.Text = e.CurrentProgress
        End Sub

    and i noticed that if Txtcurrentprogrees.Text  = 0 i can get the value of the calss normally

    but when i can't get the values Txtcurrentprogrees.Text The number is increasing  non stop

    why?



    Sunday, October 27, 2019 3:19 PM
  • Hi,

    According to your description, your issue is more related about asp.net. And this forum is discussing and asking questions about the vb.net.

    Ask in the following forum.

    https://forums.asp.net/

    Thank you for your understanding.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 28, 2019 6:31 AM