Page 1 of 1

How do I get data from a web site into my program?

Posted: Mon May 22, 2006 2:35 pm
by Ron
Hello, I am new at this so please bear with me. I have written a program that takes numbers and sorts them. I have found a web site that has the numbers I want to use. These numbers change daily. How do I add program that will get these numbers and put them into my program without me having to key each one everytime. Thank you and remember, I am not the sharpest knife in the drawer so don't answer over my head..

Posted: Mon May 22, 2006 7:44 pm
by Theophage
First, the bad news:

I don't think you can access any part of a website directly from QBASIC. Others may correct me if I am wrong, but I'm pretty sure I'm right.

Next, the good news:

QBASIC can read things out of a file on your computer. If there are many figures, you can cut and past the lot of them into a .txt file, and your QBASIC program can open that file and read the numbers out.

For info how to do this, look up the commands OPEN, INPUT#, and GET# in the QBASIC help file. Can I see the website with the numbers? Perhaps then I can give you more specifics on how to write the program for it.

Posted: Tue May 23, 2006 2:42 am
by RayBritton
I don't think you can access any part of a website directly from QBASIC. Others may correct me if I am wrong, but I'm pretty sure I'm right.
They was once a QB web browser (it ran from DOS i think), it text only and didn't work with most sites

F+ NetSite

Posted: Tue May 23, 2006 6:18 pm
by Brandon
I make (in QB) a browser called F+ NetSite it uses a program called GetNET to get data from the internet. It doesn't read HTML but has its own scripting language.

For GetNet:
http://brandoncornell.com/Files/getnet.zip

For F+ Net Site:
http://www.brandoncornell.com/modules/m ... id=2&lid=6

If you need anyother help e-mail me at admin@brandoncornell.com

Posted: Wed May 24, 2006 5:45 am
by ShadowWolf
or you could just use freebasic that way you can use winsock. there is even a demo for using HTTP in one of the winsock examples.

Posted: Wed May 24, 2006 11:24 pm
by anarky
I think schools need to surf the web a bit more and discover Freebasic. I don't even use QB anymore.

>anarky

Posted: Thu May 25, 2006 5:01 am
by Theophage
What??? HERETIC!!!




me neither...

Thank you for your input

Posted: Thu May 25, 2006 8:16 am
by Ron
Thank you all for answering my question. Can I have my program read a file in WORD? I can copy the information I want on this website, into Word. I would like for my program to look at this data in Word and pull out certain data and then run that through my program. I am not sure I know enough about this to describe what I am trying to do, but if any of you can figure out what I am want to do I would appreciate any help you could give me. Thanks again

Posted: Thu May 25, 2006 1:11 pm
by Z!re
Learn to do network programming
Make a HTTP grabber
Learn the WORD format
Make a WORD reader/writer
Combine the two

There ya go.

Posted: Fri May 26, 2006 9:22 am
by ShadowWolf
word has some nasty formating information , so i would really go with a simple TXT file.

although i am a bit confused i though orignal what you want was a information on a web page . like in a html file if that the case you just need to writte a http graber like Z!re says (there a demo in freebasic example folder in one of the winsock example for this)
crab the page and parser out the information you want.

if its in a word document on the page then its a lot more complex you still need the http graber to dl the file. and then you need to parser out microsofy evil word document.

Posted: Fri May 26, 2006 3:13 pm
by Zim
Yanno, if you want to complicate things, but only a little... realize that a web page is HTML (well, many of them) and that's just text with ASCII tags. If the page is always the same it wouldn't be hard to write a program that scans a saved copy for the starting point, then read/parse the data from that point on.

If you were really good, you could make your program read the file from the 'Temporary Internet Files" folder, so you wouldn't even have to save anything. It would already be there.

I wrote an "on-line connection timer" that way by turning on modem logging then opening and parsing the modem log created by the dial-up connection. After each dial-up session I could immediately view my on-line time for the month.

Maybe use wget.exe?

Posted: Tue Aug 01, 2006 11:55 pm
by Stoves
To retrieve a web page in qbasic, you could make use of the wget.exe utility. (I believe it's a unix command that was ported to windows.)

I was able to use it to create a program that downloads webpage information from a particular site (using wget) and then parses the page through OPEN and LINE INPUT statements. Then based on that information, I use wget again to download other files from the site. The wget command has a lot of sweet options that make it quite versatile.

I suppose perl would be a better language to parse the downloaded text with, but Qbasic is more fun. :)

Anyway, refer to http://www.interlog.com/~tcharron/wgetwin.html and click on the second link with text: "wgetwin-1_5_3_1-binary.zip" to download a copy of wget.exe.

In your QB program, simply include a line of code like:

SHELL "wget -Owebpage.htm " + url$

As long as you have the wget.exe command in the working directory, wget will download the page for you. (You can also make it a common command with environmental variables, but I never messed with that myself.) Then it's just a matter of OPENing the downloaded html file and parsing out the info you need.

*(One tricky part for me was including the quotation marks around the URL. I had to use CHR$(34) to actually include the quotation marks when constructing the url$. Hope this saves you some headache.)

Posted: Wed Aug 02, 2006 1:50 pm
by moneo
Hey, Stoves, that's very interesting info about WGET.EXE. I must look into it. Thanks!

*****