Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to display web page?

Author
Message
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Jun 2016 14:21 Edited at: 29th Jun 2016 14:39
Hello guys. Need some pointer here.

Let's say if I wanted to use DBPro to display the texts and pictures in this wikipedia page
https://en.wikipedia.org/wiki/Emu_War

How would I go about to do that using DBPro HTTP commands? Or should I use some other plugins/tools?



.....and yes, I'm a zero at web thingies. God, kill me now
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2016 17:25
Check your @Plaza post on the wip board.
Attila
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 1st Jul 2016 14:57
here is an example of creating and showing a HTML-Page



hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 1st Jul 2016 17:20 Edited at: 1st Jul 2016 17:20
So that's how html file is formatted.

Any idea on how to obtain the paragraph part from a website?
<p>This is a paragraph</p>

I assume that's the where the bulk of texts are in any websites?
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 2nd Jul 2016 05:17
if all you want is the text and image links then you customize some html stripping code. Luckly, many people have written Html strippers (Example: Strip html ) around here so there's a lot of basis code.








PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 2nd Jul 2016 13:39 Edited at: 2nd Jul 2016 13:51
Thank's! That would be super useful to get me started.


Anybody knew what happened to DBPro command?
D3D_MAKE_3DTEXT

It really makes 3D text objects? Why can't I see it in our current DBPro command list?

Woops found this 3D text plugin. WIll try
https://forum.thegamecreators.com/thread/69221
Attila
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 2nd Jul 2016 14:46
You asked how to display a webpage, the examle creates and displays a html-page. What do you want to do, download and parse a page from the www? Are you trying to write a browser?
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 3rd Jul 2016 05:05
I was trying to obtain the resources (texts, images, links), and to display them in 3D environment that we can explore.

For example,
- taking all the text and turn them into 3D text with D3D plugin.
- Texture cubes with pictures from the website.
- make a character so we can walk in that 3D space, and interact with the above

Initially I thought that If I knew how to display webpages, I would also know how obtain individual resources from websites. But I guess it's not that easy.


Attila
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 3rd Jul 2016 22:59 Edited at: 3rd Jul 2016 23:02
To display a html-page - as you describe it - you must interpret the html-code and (on most pages) the stylesheet information. Images are external references in the html-code and thei must be downloaded separately. I found some code (in C) that you can use to render a webpage ( https://htmlrenderer.codeplex.com/ ). You can use it to create a dll an call it from your program.

Downloading a webpage can be done by a dll-call in DarkBasic


A file created with the download, then can be opened with "open to read" and parsed for the required information.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 5th Jul 2016 04:13
Wow that's really useful! I can even use the example to learn html/look for ways to strip resources.

If there's any more basic html things that you guys think I should know to:
Quote: "display website elements in 3D environment that we can explore"

please let me know!
Attila
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 6th Jul 2016 17:37 Edited at: 6th Jul 2016 17:38
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 15th Jul 2016 04:15 Edited at: 15th Jul 2016 04:31
I tried out the function to download web page, but the program seems to crash.
Can't find any downloaded webpage either.

Noticed anything wrong?



Quote: "if all you want is the text and image links then you customize some html stripping code. Luckly, many people have written Html strippers (Example: Strip html ) around here so there's a lot of basis code. "

I tried the HTML stip code, but it seems that we need to login to view full source code. Currently that website disabled registration.
Do we have any other example HTML-stripper in BASIC around here?
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2016 06:12 Edited at: 15th Jul 2016 06:29
If you are trying to get your external ip from this site. This code works, even with the verb string NULL as well.

WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2016 06:44 Edited at: 15th Jul 2016 08:08
This code will do the same using URLDownloadToFileA.

hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 15th Jul 2016 08:44
Hey, thanks a lot! That works.

Next, I'm going to parse the downloaded webpage into 3D world that we can play in.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 15th Jul 2016 08:52 Edited at: 15th Jul 2016 09:14
I downloaded webpage https://en.wikipedia.org/wiki/Emu

I noticed that when we call
Quote: "read string 1, ip"

DBPro read the string <!DOCTYPE html>
If we call again READ STRING, then DBPro will read the next caged string <html lang="en" dir="ltr" class="client-nojs">

My question is, how does DBPro read strings from a file?
Does it stop reading after every <>, or any other punctuation or something? Does it read line by line?
Can we read everything in the .txt file and store it in a single string in one go?
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2016 17:56 Edited at: 15th Jul 2016 18:09
DBPro reads the file line by line. The file is delimited by a newline character. Notepad will show the file as a continues because it requires a carriage return/newline.

I'm not sure if DBPro strings have a limit or what that limit would be, if they do. You could try reading the file with Read String and concatenate a buffer string until the end-of-file is reached. If that don't work, I have code in my archives that should do the trick.

Edit: Here is a tool every programmer should have - HexEdit.

Login to post a reply

Server time is: 2024-03-28 17:53:27
Your offset time is: 2024-03-28 17:53:27