B4J Question Getting a table from a Web page

SMOOTSARA

Active Member
Licensed User
Longtime User
Hello friends

I want to get a table from a web page (http://www.verbix.com/translate/fr/Manger)
I'm trying download and save html page with the HttpJob library

B4X:
 url = "http://www.verbix.com/translate/fr/Mangerhtml"
            job.Initialize(xxx, Me)
            job.Download(url)

How can I get this table and save to html string?

Thanks
 

Attachments

  • 111.PNG
    111.PNG
    117.8 KB · Views: 231

Sandman

Expert
Licensed User
Longtime User
How can I get this table and save to html string?

It's really simple. The first thing to note is that the webpage is doing the lookup using ajax, which means it's likely communicating with an api. Looking at the network requests, it's very simple to find the endpoint, which is returning jsonp (which is like json, with a little extra stuff).

https://api.verbix.com/translator/i...nslation=getVerbixTranslation&_=1531227868644

It's quite common that some unneeded info is tucked on, and just looking at it I can see that the last value probably is for some sort of tracking. So I tried to remove that, and it worked just fine anyway. Also, let's try to remove the jsonp parameter, because you don't want the result returned as jsonp. All in all, this gives us this url:

https://api.verbix.com/translator/i...ger?getVerbixTranslation=getVerbixTranslation

If you try that url, you'll see that you're getting all data back as a nice json. Copy that and paste it into Erels json parser at http://basic4ppc.com:51042/json/index.html to get a feel for how you access the data.


Note that the API isn't really meant for using like this, so it's not entirely impossible they will change something at some point - and your app will break.
 
Upvote 0

SMOOTSARA

Active Member
Licensed User
Longtime User
It's quite common that some unneeded info is tucked on, and just looking at it I can see that the last value probably is for some sort of tracking. So I tried to remove that, and it worked just fine anyway. Also, let's try to remove the jsonp parameter, because you don't want the result returned as jsonp. All in all, this gives us this url:

https://api.verbix.com/translator/i...ger?getVerbixTranslation=getVerbixTranslation

Hello
I was really amazed at your very precise answer
I'm going to get a file in Java code for a few days and I can not
You may be more likely to know how to do this
I thank you for your advice
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You may be more likely to know how to do this
Sorry, but no. Javascript (NOT JAVA!) is not in the list of my known Programming Languages.

Based of the second link you posted i guess you should go that way! Getting the json-result from the api and then iterate over the results.

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As List = parser.NextArray
For Each colroot As Map In root
 Dim name As String = colroot.Get("name")
 Dim id As String = colroot.Get("id")
 Dim meanings As List = colroot.Get("meanings")
 For Each colmeanings As Map In meanings
  Dim languages As List = colmeanings.Get("languages")
  For Each collanguages As Map In languages
   Dim name As String = collanguages.Get("name")
   Dim verbs As List = collanguages.Get("verbs")
   For Each colverbs As String In verbs
   Next
   Dim id As String = collanguages.Get("id")
   Dim t1 As String = collanguages.Get("t1")
  Next
  Dim name As String = colmeanings.Get("name")
  Dim id As Int = colmeanings.Get("id")
 Next
Next
 
Upvote 0

SMOOTSARA

Active Member
Licensed User
Longtime User
Sorry, but no. Javascript (NOT JAVA!) is not in the list of my known Programming Languages.

Based of the second link you posted i guess you should go that way! Getting the json-result from the api and then iterate over the results.

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As List = parser.NextArray
For Each colroot As Map In root
 Dim name As String = colroot.Get("name")
 Dim id As String = colroot.Get("id")
 Dim meanings As List = colroot.Get("meanings")
 For Each colmeanings As Map In meanings
  Dim languages As List = colmeanings.Get("languages")
  For Each collanguages As Map In languages
   Dim name As String = collanguages.Get("name")
   Dim verbs As List = collanguages.Get("verbs")
   For Each colverbs As String In verbs
   Next
   Dim id As String = collanguages.Get("id")
   Dim t1 As String = collanguages.Get("t1")
  Next
  Dim name As String = colmeanings.Get("name")
  Dim id As Int = colmeanings.Get("id")
 Next
Next


hi
I do not have a problem with Jason!
I need to know how to find the json_link from this page?!!
 
Upvote 0
Top