Android Question MiniHtmlParser problem - Error occurred on line: 236 (MiniHtmlParser)

mcqueccu

Well-Known Member
Licensed User
Longtime User
Hello, am trying to use minihtmlparser to get youtube direct download link from this website
But when i run the app, sometimes the same link will work, sometimes it will crash.

Currently I use Try and Catch, sometimes it will return "Not Found" but when you try again then it gives result

Edit: The link i want is in this format


B4X:
Sub getYoutubeLink(content As String) As String
    Dim link As String
    Try
        Dim parser As MiniHtmlParser
        parser.Initialize
        Dim root As HtmlNode = parser.Parse(content)
        Dim sf_result As HtmlNode = parser.FindNode(root,"div",parser.CreateHtmlAttribute("id","sf_result"))
       
        parser.PrintNode(sf_result) 'For debugging
       
        Dim btnbox As HtmlNode = parser.FindNode(sf_result,"div",parser.CreateHtmlAttribute("class","def-btn-box"))
        Dim atag As HtmlNode = parser.FindNode(btnbox,"a",Null)
   
        link = parser.GetAttributeValue(atag,"href",Null)
    Catch
        Log(LastException)
        link = "Not Found"
    End Try
   
    Return cleanAmp(link)
End Sub

Sub cleanAmp(link As String) As String
    Return link.Replace("amp;","")
End Sub

B4X:
** Activity (main) Resume **
Loading....
Finished Loading
*** div ***
|id: sf_result|
*** div ***
|class: media-result|
  *** div ***
  |class: result-box video|
  |hid: 101|
   *** text ***
   |value:  |
   *** div ***
   |class: thumb-box thumb-272 |
    *** text ***
    |value:  |
    *** a ***
    |href: #|
    |class: clip|
    |id: video_player_1597813805170_5578|
     *** text ***
     |value:  |
     *** img ***
     |src: https://i.ytimg.com/vi/CSa6Ocyog4U/hqdefault.jpg|
     |class: thumb|
     *** text ***
     |value:  |
     *** span ***
     |class: play-btn|
   *** text ***
   |value:  |
   *** div ***
   |class: info-box|
    *** text ***
    |value:  |
    *** div ***
    |class: meta|
     *** text ***
     |value:  |
     *** div ***
     |class: row title|
     |title: Flutter Travel UI Tutorial - Apps From Scratch|
      *** text ***
      |value: Flutter Travel UI Tutorial - Apps From Scratch|
     *** text ***
     |value:  |
     *** div ***
     |class: row duration|
      *** text ***
      |value: 01:02:48|
    *** text ***
    |value:  |
    *** div ***
    |class: link-box|
     *** text ***
     |value:  |
     *** div ***
     |class: def-btn-box|
      *** a ***
      |title: video format: 720|
      |class: link link-download subname ga_track_events download-icon|
      |download: Flutter Travel UI Tutorial - Apps From Scratch.mp4|
      |quality: 720|
      |type: mp4|
      |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=22&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fmp4&ratebypass=yes&dur=3768.180&lmt=1571823611151442&mt=1597808494&fvip=2&fexp=23883098&c=WEB&txp=2316222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgd8_MozuqjcJfBgANaz4mzgHQSq1ayetfxcwNel0JgSYCIQCZIC_HnToKvwF2cRbPO69BFVSMoZWYAWJzjGu9Kr0pgg%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&contentlength=200864349&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
      |event: send;event;result;click;101|
       *** text ***
       |value: Download|
     *** div ***
     |class: drop-down-box|
      *** text ***
      |value:  |
      *** div ***
      |class: def-btn-name|
       *** text ***
       |value: MP4 |
       *** span ***
       |class: subname|
        *** text ***
        |value: 720|
      *** text ***
      |value:  |
      *** div ***
      |class: list|
       *** text ***
       |value:  |
       *** div ***
       |class: links|
        *** text ***
        |value:  |
        *** div ***
        |class: main|
         *** div ***
         |class: link-group|
          *** a ***
          |title: video format: 720|
          |class: link link-download subname ga_track_events|
          |download: Flutter Travel UI Tutorial - Apps From Scratch.mp4|
          |quality: 720|
          |type: mp4|
          |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=22&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fmp4&ratebypass=yes&dur=3768.180&lmt=1571823611151442&mt=1597808494&fvip=2&fexp=23883098&c=WEB&txp=2316222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgd8_MozuqjcJfBgANaz4mzgHQSq1ayetfxcwNel0JgSYCIQCZIC_HnToKvwF2cRbPO69BFVSMoZWYAWJzjGu9Kr0pgg%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&contentlength=200864349&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
          |event: send;event;result;click;101|
           *** text ***
           |value: MP4 |
           *** span ***
           |class: subname|
            *** text ***
            |value: 720|
          *** a ***
          |title: video format: 360|
          |class: link link-download no-downloadable subname ga_track_events|
          |download: Flutter Travel UI Tutorial - Apps From Scratch.mp4|
          |quality: 360|
          |type: mp4|
          |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=18&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fmp4&gir=yes&clen=157023425&ratebypass=yes&dur=3768.180&lmt=1571823284810506&mt=1597808494&fvip=2&fexp=23883098&c=WEB&txp=2311222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAPPAxFJEzAeLe9Qkd2Ql2ZfkwUVY-39-JnB0DONk889yAiAIo1NrEOqK40hVHzJ0_Kpj3AZLlL8ZdzHARo-kexGZYw%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
          |event: send;event;result;click;101|
           *** text ***
           |value: MP4 |
           *** span ***
           |class: subname|
            *** text ***
            |value: 360|
         *** div ***
         |class: link-group|
          *** a ***
          |title: video format: 1080 (without audio)|
          |class: no-audio link link-download no-downloadable subname ga_track_events|
          |download: Flutter Travel UI Tutorial - Apps From Scratch.mp4|
          |quality: 1080|
          |type: mp4 dash|
          |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C298%2C299%2C302%2C303&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fmp4&gir=yes&clen=231326617&dur=3768.101&lmt=1571823394254398&mt=1597808494&fvip=2&keepalive=yes&fexp=23883098&c=WEB&txp=2316222&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAP5riEePp7jHKZh_hWE_5yJVFN6cogKDmgCKoBpZECE0AiBOERwE45qKY4yJs38SYgxhr5hG1TWrwa1j8s3CWC56IQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
          |event: send;event;result;click;101|
           *** text ***
           |value: MP4 |
           *** span ***
           |class: subname|
            *** text ***
            |value: 1080|
          *** a ***
          |title: video format: 1080 (without audio)|
          |class: no-audio link link-download no-downloadable subname ga_track_events|
          |download: Flutter Travel UI Tutorial - Apps From Scratch.mp4|
          |quality: 1080|
          |type: mp4 dash|
          |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=299&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C298%2C299%2C302%2C303&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fmp4&gir=yes&clen=248722802&dur=3768.114&lmt=1571823394254985&mt=1597808494&fvip=2&keepalive=yes&fexp=23883098&c=WEB&txp=2316222&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAKdKV5DDscg7pS7BM-9FyZ8m85QCwfBybmhXdS6O9-PKAiEA6Y-pexRPEmglbmH_17gpy_HFLIElyt2YaGwMDbtI560%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
          |event: send;event;result;click;101|
           *** text ***
           |value: MP4 |
           *** span ***
           |class: subname|
            *** text ***
            |value: 1080p60|
         *** div ***
         |class: link-group|
          *** a ***
          |title: video format: 1080 (without audio)|
          |class: no-audio link link-download no-downloadable subname ga_track_events|
          |download: Flutter Travel UI Tutorial - Apps From Scratch.webm|
          |quality: 1080|
          |type: webm dash|
          |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C298%2C299%2C302%2C303&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fwebm&gir=yes&clen=189789302&dur=3768.097&lmt=1571823400356240&mt=1597808494&fvip=2&keepalive=yes&fexp=23883098&c=WEB&txp=2316222&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgKU3X5xBCVD2eMC79gXSN2EChVS1g-v2zDu2bAl5LhzYCIQD97QuyKTqfZr4oURH_jrDmjkxu18m4TjFke-yOFfyKJA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
          |event: send;event;result;click;101|
           *** text ***
           |value: WEBM |
           *** span ***
           |class: subname|
            *** text ***
            |value: 1080|
          *** a ***
          |title: video format: 1080 (without audio)|
          |class: no-audio link link-download no-downloadable subname ga_track_events|
          |download: Flutter Travel UI Tutorial - Apps From Scratch.webm|
          |quality: 1080|
          |type: webm dash|
          |href: https://r2---sn-4ox-ixae.googlevideo.com/videoplayback?expire=1597830242&ei=AqA8X5SmK9LL7gSQ4IzADw&ip=2a0c%3Af040%3A%3Aea39%3A35ff%3Afe24%3A25f8&id=o-AGqiKxu0Vxc6jdkFmDG20ODSvzR6eHMchwb5jp2QIWIf&itag=303&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C298%2C299%2C302%2C303&source=youtube&requiressl=yes&mh=8D&mm=31%2C29&mn=sn-4ox-ixae%2Csn-5goeen7y&ms=au%2Crdu&mv=m&mvi=2&pl=48&initcwndbps=813750&vprv=1&mime=video%2Fwebm&gir=yes&clen=204679378&dur=3768.114&lmt=1571823400357006&mt=1597808494&fvip=2&keepalive=yes&fexp=23883098&c=WEB&txp=2316222&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgH0mEVzqFdnUMqMvgaM58dRkIkNtBD065dvsEos5twckCIDK6ML4ehr4l03ALVIoiMQGTZKyTjoA9zNi0Goo64I58&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgZ6ViEAtOxKcH1OFi9S-16Udw6VxjCQV5IEhN-puris8CIDEaHnWq_goJd4pKI65cx8xIH5my-6uSgzE3szxOmz9M&video_id=CSa6Ocyog4U&title=Flutter+Travel+UI+Tutorial+-+Apps+From+Scratch|
          |event: send;event;result;click;101|
           *** text ***
           |value: WEBM |
           *** span ***
           |class: subname|
            *** text ***
            |value: 1080p60|
     *** div ***
     |class: def-file-info|
  *** div ***
  |class:  sf-helper extra|
  |href: https://addons.mozilla.org/ru/firefox/addon/savefromnet-helper/?vid=313&utm_source=savefrom&utm_medium=vidacha&utm_campaign=sf_helper&utm_content=101-promo|
  |event: send;event;vidacha;helper-promo-click;101|
  |style: display: block;|
   *** div ***
   |class: center|
    *** text ***
    |value:  |
    *** img ***
    |src: /img/extension/icon_32.png|
    *** text ***
    |value:  
      Install the |
    *** a ***
    |target: _blank|
    |href: https://play.google.com/store/apps/details?id=org.mozilla.firefox|
     *** text ***
     |value: FireFox mobile|
    *** text ***
    |value:  browser along with the |
    *** a ***
    |target: _blank|
    |href: https://addons.mozilla.org/ru/firefox/addon/savefromnet-helper/?vid=313&utm_source=savefrom&utm_medium=vidacha&utm_campaign=sf_helper&utm_content=101-promo|
    |class: ga_track_events bold|
    |event: send;event;vidacha;helper-promo-click;101|
     *** text ***
     |value: SaveFrom.net helper extension|
    *** text ***
    |value:  to download from |
    *** b ***
     *** text ***
     |value: YouTube|
    *** text ***
    |value:  in one click
    |

B4X:
Service started in the background. Trying to start again in foreground mode.
*** Service (starter) Create ***
** Service (starter) Start **
Service started in foreground mode.
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
Loading....
Finished Loading
Error occurred on line: 236 (MiniHtmlParser)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.leafecodes.youtube.minihtmlparser._findnode(minihtmlparser.java:132)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.ShellBA$1.run(ShellBA.java:77)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7814)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
loading
loading
Error occurred on line: 236 (MiniHtmlParser)
java.lang.NullPointerException
    at b4j.example.minihtmlparser._findnode(minihtmlparser.java:132)
    at b4j.example.main._extractyoutubelink(main.java:174)
    at b4j.example.main._wv_pagefinished(main.java:205)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:216)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tested it with:
B4X:
Dim parser As MiniHtmlParser
parser.Initialize
Dim root As HtmlNode = parser.Parse(File.ReadString("C:\Users\H\Downloads\result.txt", "")) 'B4J
Dim sf_result As HtmlNode = parser.FindNode(root,"div",parser.CreateHtmlAttribute("id","sf_result"))
Dim btnbox As HtmlNode = parser.FindNode(sf_result,"div",parser.CreateHtmlAttribute("class","def-btn-box"))
Dim atag As HtmlNode = parser.FindNode(btnbox,"a",Null)
Log(parser.GetAttributeValue(atag,"href",Null))
The output looks correct.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
Yes, the B4J crashes less often than the B4A, also the crash happens more frequent in direct online link than saved link.

Kindly test the exported B4A sample above and put this link in it -https://www.youtube.com/watch?v=bInJjmH31Hk
you will see it will return "Not found" and when you click the button multiple times before the link will be generated.

Edit: The try catch block out gives this error

(NullPointerException) java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
 
Last edited:
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
The code you posted and mine are the same from what I can see. And from my post you can see I said the B4J app rarely crash that's why I wanted you to test with the B4A.

With the B4A sample project I posted above, it's when you put in the YouTube link, sometimes you have to click the button to retry couple of times before you get the link - because of the try and catch block.

But without the try and catch, it crashes immediately

So my post #5 is just trying to give you the steps to reproduce the crash
 
Upvote 0
Top