Showing tv guide

Hi,

How can I show the TV guide from a cable provider in a basic4ppc form, retrieving the tv guide information for a specific TV channel from provider web page.

Best regards
 

mjcoon

Well-Known Member
Licensed User
I think you'll need to study the HTTP library, the "Overview" of which has some pointers to descriptions of the operation of the protocol.

Mike.
 
When i try the example from http help file


'Request is a WebRequest object, Response is a WebResponse object
'Reader and Writer are BinaryFile objects.
Sub Globals
dim Buffer(0) as byte
End Sub


Sub App_Start
Form1.Show
URL = "http://www.b4x.com/forum/images/Basic4ppc2.gif"
DownloadFile(AppPath & "\NewImage.gif",URL)
Form1.Image = "NewImage.gif"
URL = "http://en.wikipedia.org/wiki/HTTP"
TextBox1.Text = GetText(URL) 'TextBox1 is a multiline textbox.
End Sub


Sub GetText (URL)
Response.New1
Request.New1(URL)
Response.Value = Request.GetResponse 'This line calls the server and gets the response.
string = Response.GetString 'Get the Response string.
Response.Close
return string
End Sub


Sub UploadFile (UploadFile, URL) 'Requires a server with write permission.
Response.New1
Request.New1(URL)
Request.Method = "PUT"
Writer.New1(Request.GetStream,true) 'Use a BinaryFile object to write the data to the Request stream.
dim Buffer(4096) as byte
FileOpen(c1,UploadFile,cRandom)
Reader.New1(c1,true) 'Reads the local file.
count = Reader.ReadBytes(buffer(),4096)
Do While count > 0
Writer.WriteBytes2(buffer(),0,count)
count = Reader.ReadBytes(buffer(),4096)
loop
FileClose(c1)
Request.GetResponse 'Launch the request (upload the file).
End Sub


Sub DownloadFile (LocalFile,URL)
Response.New1
Request.New1(URL)
Response.Value = Request.GetResponse 'Launch the request and get the response.
Msgbox("Download size: " & Response.ContentLength) 'Show the file size.
Reader.New1(Response.GetStream,true) 'Use a BinaryFile object to read the data from the Response stream.
FileOpen(c1,LocalFile,cRandom)
Writer.New1(c1,false)
dim buffer(4096) as byte
count = Reader.ReadBytes(buffer(),4096)
do while count > 0
Writer.WriteBytes2(buffer(),0,count)
count = Reader.ReadBytes(buffer(),4096)
loop
FileClose(c1)
Response.Close 'Close the Response stream.
Msgbox("File saved.")
End Sub


I get the error:

Error compiling program
Error description: response is not a Known control or object
Ocurred in line 17
response.New1

:BangHead:
 

mjcoon

Well-Known Member
Licensed User
Again, because you do not attach the whole SBP file we cannot check, but possibly you have not added the library objects through the Tools menu.

Mike.
 
HI,

I miss the objects. I already manage to put the example working with the TV guide Webpage.
But its not ok, because it reads the all Web page with a lot of garbled chars and prints it in a multiline textbox in the form..
The tv Guide is there in the mmiddle but its not ok. is any way too read only the Tv guide data and not all the content of the webpage?

Best regards
 
i Think what i need to do is read the web site as XML.
i found that the information i need is betwween <li> and <\li> tags .
How can i reead all the lines betwwen the tags (Parse XML) ?
Can someone put an example please of how to do it?

:BangHead::BangHead:
Best regards
 

mjcoon

Well-Known Member
Licensed User
i found that the information i need is betwween <li> and <\li> tags .
How can i reead all the lines betwwen the tags (Parse XML) ?

To read lines between tags suggests use of editing functions within B4P Strxxx().

To read the XML structure with <li> tags you could read it as a document and then use GetElementsByTagName("li").

To use XML.dll I think you will need to buy B4P.

But you need a proper analysis of the structure to determine how to display by making the portion that you want to view into a new document.

Mike.
 

mjcoon

Well-Known Member
Licensed User
and if i load web page as txt , how can i read between li tags

This is elementary programming!

Perhaps get the offsets with
B4X:
offset1 = StrIndexOf (htmlString, "<li>", 0)
offset1 = offset1 + StrLength("<li>)
offset2 = StrIndexOf (htmlString, "</li>", offset1)

(Note: you wrote <\li> which I think will be wrong.)

Then extract the text between offsets...

Mike.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…