It is currently Tue Jun 27, 2017 10:25 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Can I transfer the html page into a string?
Unread postPosted: Fri Feb 03, 2017 5:10 pm 
Offline
User avatar

Joined: Sun May 19, 2013 10:53 am
Posts: 514
I am calling a site with HTML.LOAD.URL comand, the page is a json formatted data and I need to transfer all the data into a string for parsing and selecting the needed values. Is it possible ? If yes which is the command?

Alberto

_________________
Even those who assert that everything is predestined and that
we can change nothing about it, still look both ways before they cross the street!


Top
 Profile  
 
 Post subject: Re: Can I transfer the html page into a string?
Unread postPosted: Sun Feb 05, 2017 6:32 pm 
Offline

Joined: Wed Mar 05, 2014 1:15 am
Posts: 59
Hello.

I think that it is not a very good answer....

I use "GARBURL" instruction when get JSON.

Code:
GRABURL jsonx$,"https://itunes.apple.com/us/rss/toppaidebooks/limit=10/json"


A character string is set to "jsonx$", so edit this string.

I use "replace$()","split" instruction in "for-next" loop.

I do not know it is the best way.

_________________
Sinagawa1

BASIC! beginner in Japan.

Sinagawa-ku, Tokyo Japan

URL:BASIC! Youtube video gallery(Japanese Langage Page)
http://www.geocities.jp/a_33/you/gallery.html
-------------------------


Top
 Profile  
 
 Post subject: Re: Can I transfer the html page into a string?
Unread postPosted: Mon Feb 06, 2017 3:14 am 
Offline
User avatar

Joined: Tue Sep 13, 2011 4:58 am
Posts: 722
Location: Sao Paulo, Brasil
I used that before and worked very well. Parsed the string and got the data I needed from the xml file.

_________________
Alfredo Peine

-------------

Hisense Sero 7 Pro (Tegra 3 7" rooted tablet - Android 4.4.4) / Moto G 3rd Gen (5" quad core rooted phone - Android 6.0).


Top
 Profile  
 
 Post subject: Re: Can I transfer the html page into a string?
Unread postPosted: Wed Feb 08, 2017 5:18 am 
Offline
User avatar

Joined: Sun May 19, 2013 10:53 am
Posts: 514
I am using GRABURL as well at the moment, but it is very slow to download! I am using a 60000 timeout and once every five call it timeout.

HTML.URL.LOAD is definetly quicker, tested it several Times and still performance are not comparable with GRABURL.

The point is that I don't know how to move the page content into a string variable of mine.

Alberto

_________________
Even those who assert that everything is predestined and that
we can change nothing about it, still look both ways before they cross the street!


Top
 Profile  
 
 Post subject: Re: Can I transfer the html page into a string?
Unread postPosted: Thu Feb 09, 2017 9:29 pm 
Offline

Joined: Wed Mar 05, 2014 1:15 am
Posts: 59
Alberto wrote:
The point is that I don't know how to move the page content into a string variable of mine.

Hello.

I have another way.

This method uses "javascript pseudo protocol".

As follows:

Code:
html.load.url "javascript:Android.dataLink(document.getElementsByTagName('pre')[0].innerHTML);"


Note:
1.I do not know if this method is fast.
2.I do not know if this method is good.

The test program to get iTunes JSON is as follows:

Code:
console.title "HTML test"


nxttest:

HTML.OPEN

! Load JSON
HTML.LOAD.URL "https://itunes.apple.com/us/rss/toppaidebooks/limit=10/json"

! wait ready HTML screen
pause 5000

! Send javascript pseudo protocol
html.load.url "javascript:Android.dataLink(document.getElementsByTagName('pre')[0].innerHTML);"

xnextUserAction:

! loop until data$ is not ""

DO
HTML.GET.DATALINK data$
UNTIL data$ <> ""

type$ = LEFT$(data$, 4)

data$ = MID$(data$,5)

! Act on the data type
! Shown are all the current data types

SW.BEGIN type$

! Back Key hit.
! if we can go back then do it
SW.CASE "BAK:"
  PRINT "BACK key: " + data$
  popup "stopped",0,0,0
  pause 2000
  end
  SW.BREAK

! A hyperlink was clicked on
SW.CASE "LNK:"
  PRINT "Hyperlink selected: "+ data$
  popup "loading...",0,0,1
!  HTML.LOAD.URL data$
  browse data$


  SW.BREAK

! An error occured
SW.CASE "ERR:"
  PRINT "Error: " + data$
  popup "error stopped.",0,0,0
  pause 2000
  exit
  SW.BREAK

! JSON data returned
SW.CASE "DAT:"
  PRINT "User data: " + data$
 
  msx$=data$+"---->data"
  popup msx$,0,0,0

  pause 1000

  html.close
  end

  SW.BREAK

! Form data returned.
! Note: Form data returning
! always exits the html.

SW.CASE "FOR:"
  PRINT "Form data: "+data$
  popup "ended.",0,0,0
  pause 2000
  exit
  SW.BREAK



SW.DEFAULT
  PRINT "Unexpected data type:", type$ + data$
  popup "ended.",0,0,0
  pause 2000
  exit

SW.END

GOTO xnextUserAction


end

_________________
Sinagawa1

BASIC! beginner in Japan.

Sinagawa-ku, Tokyo Japan

URL:BASIC! Youtube video gallery(Japanese Langage Page)
http://www.geocities.jp/a_33/you/gallery.html
-------------------------


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred