Android Question Decode html string

invocker

Active Member
I want to turn the percent-encoded html into a human-readable Arabic path
"><img data-lazyloaded="1" src="data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=" id="image-1465-21483-12" alt="مولر يواصل التألق في الدوري الأميركي
" data-src="ht://eighty-eight.live/wp-content/uploads/%D9%85%D9%88%D9%84%D8%B1-%D9%8A%D8%AA%D8%A3%D9%84%D9%82-%D9%81%D9%8A-%D8%A7%D9%84%D8%AF%D9%88%D8%B1%D9%8A-%D8%A7%D9%84%D8%A3%D9%85%D9%8A%D8%B1%D9%83%D9%8A.png" class="ct-image" data-srcset="" data-sizes="(max-width: 300px) 100vw, 300px" data-id="image-1465-21483"></div><div id="div_b-1466-21483-12" class="ct-div-block" data-id="div_b-1466-21483"><h3 id="headline-1467-21483-12" class="ct-headline" data-id="headline-1467-21483"><span id="span-1468-21483-12" class="ct-span" data-id="span-1468-21483"><a href="h://eighty-eight.live/%d8%b1%d8%ad%d9%8a%d9%84-%d8%a2%d8%b1%d9%86%d9%8a-%d8%b3%d9%84%d9%88%d8%aa-%d9%87%d9%84-%d8%aa%d8%aa%d8%a3%d8%ab%d8%b1/">رحيل آرني سلوت وتأثيره على ليفربول</a></span></h3></div></div><div class="oxy-repeater-pages-wrap"><div class="oxy-repeater-pages">
<span aria-current="page" class="page-numbers current">1</span>


B4X:
Wait For (http) jobdone (http As HttpJob)
If http.Success Then
        Dim html As String =   (http.GetString)
        Log(html)
    End If
 

emexes

Expert
Licensed User
Longtime User
turn the percent-encoded html into a human-readable Arabic path

The % encoding looks like it is UTF-8 (or perhaps UTF-16 or 16-bit Unicode) in ASCII hex. If you don't find an existing library or system call to convert it from ASCII to Unicode, let me know - it looks straightforward enough to do, but if somebody's already put the effort into doing it, there's no point repeating that effort.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim s As String = "%D9%85%D9%88%D9%84%D8%B1-%D9%8A%D8%AA%D8%A3%D9%84%D9%82-%D9%81%D9%8A-%D8%A7%D9%84%D8%AF%D9%88%D8%B1%D9%8A-%D8%A7%D9%84%D8%A3%D9%85%D9%8A%D8%B1%D9%83%D9%8A.png"
Dim su As StringUtils
Log(su.DecodeUrl(s, "utf8"))
مولر-يتألق-في-الدوري-الأميركي.png

And you can use MiniHtmlParser to get the relevant element.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…