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

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Ron
Newbie
Posts: 2
Joined: Mon May 22, 2006 2:26 pm

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

Post 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..
User avatar
Theophage
Coder
Posts: 44
Joined: Sun May 07, 2006 7:32 pm
Location: Tucson, AZ
Contact:

Post 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.
Daniel "Theophage" Clark
theophage (at) geocities (dot) com

"God used to be my co-pilot, but our plane crashed in the mountains and I had to eat Him..."
RayBritton
Veteran
Posts: 109
Joined: Thu Feb 10, 2005 12:38 pm

Post 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
User avatar
Brandon
Coder
Posts: 47
Joined: Sat Nov 19, 2005 9:24 pm
Location: NY
Contact:

F+ NetSite

Post 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
User avatar
ShadowWolf
Veteran
Posts: 56
Joined: Thu Mar 04, 2004 1:32 pm
Contact:

Post 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.
anarky
Coder
Posts: 37
Joined: Mon Apr 18, 2005 11:57 am
Location: Australia
Contact:

Post by anarky »

I think schools need to surf the web a bit more and discover Freebasic. I don't even use QB anymore.

>anarky
User avatar
Theophage
Coder
Posts: 44
Joined: Sun May 07, 2006 7:32 pm
Location: Tucson, AZ
Contact:

Post by Theophage »

What??? HERETIC!!!




me neither...
Daniel "Theophage" Clark
theophage (at) geocities (dot) com

"God used to be my co-pilot, but our plane crashed in the mountains and I had to eat Him..."
Ron
Newbie
Posts: 2
Joined: Mon May 22, 2006 2:26 pm

Thank you for your input

Post 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
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post 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.
I have left this dump.
User avatar
ShadowWolf
Veteran
Posts: 56
Joined: Thu Mar 04, 2004 1:32 pm
Contact:

Post 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.
User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Post 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.
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
User avatar
Stoves
Veteran
Posts: 101
Joined: Fri Feb 10, 2006 12:24 am
Location: Nashville, TN

Maybe use wget.exe?

Post 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.)
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Hey, Stoves, that's very interesting info about WGET.EXE. I must look into it. Thanks!

*****
Post Reply