How do I get data from a web site into my program?
How do I get data from a web site into my program?
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..
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.
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..."
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..."
-
- Veteran
- Posts: 109
- Joined: Thu Feb 10, 2005 12:38 pm
F+ NetSite
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
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
- ShadowWolf
- Veteran
- Posts: 56
- Joined: Thu Mar 04, 2004 1:32 pm
- Contact:
Thank you for your input
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
- ShadowWolf
- Veteran
- Posts: 56
- Joined: Thu Mar 04, 2004 1:32 pm
- Contact:
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.
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.
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.
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 ---
--- Time flies like an arrow, but fruit flies like a banana ---
Maybe use wget.exe?
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.)
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.)