• A Great friend to the HardForum with a great kid that he is trying to get a scholorship to continue his schooling. Please give hime a vote! Only 24 hours left! Thanks.
    If you have an VOTE FOR KEENAN!

"getting" text off a page

MoDsOuRcEdOtNeT

Limp Gawd
Joined
Oct 31, 2003
Messages
469
Alrite, I wanna make a program that takes directions off of mapquest and then turns it into a text file. So I searched up directions and it seems the URL has all the variables such as &state1=blah&state2=blah so that should be fairly simple. But then how would I take the directions off the top of the page and get them into the program then creating an output file with them with a given filename and dirctory. Any help would be appriciated. Also, this is going to be all in VB if possible. Thanks.
 
I don't know if this will help much, but if you have access to a Linux-like system, you can just type in this:
Code:
curl -s  "http://www.mapquest.com/directions/main.adp?go=1&do=nw&rmm=1&un=m&cl=EN&ct=NA&rsres=1&1a=&1c=New+York&1s=NY&1z=&2a=&2c=Boston&2s=MA&2z=" | grep -A 1000 '<table.*id="maneuvers">' | grep -B 1000 '<div id="googleadb"' | grep -B 1000 '</table>' | grep '<td>' | sed -e 's/ *<td>//' -e 's/<\/td>//'
...and you'll get this:
Code:
Start out going SOUTHEAST on KENMARE ST toward BOWERY.
Turn LEFT onto BOWERY.
Turn RIGHT onto E HOUSTON ST.
Merge onto FDR DR N via the ramp on the LEFT.
Take the TRIBORO BR exit- EXIT 17- on the LEFT toward I-278 / BRUCKNER EXPWY / GRAND CENTRAL PKWY.
Merge onto TRIBOROUGH BRIDGE (Portions toll).
Merge onto I-278 E toward I-87 N / BRONX / UPSTATE N Y / NEW ENGLAND.
Merge onto BRUCKNER EXPY / I-278 E via EXIT 47 toward NEW HAVEN.
BRUCKNER EXPY / I-278 E becomes I-95 N (Portions toll).
Merge onto I-91 N via EXIT 48 on the LEFT toward HARTFORD.
Merge onto CT-15 N / WILBUR CROSS HWY via EXIT 29 toward I-84 / EAST HARTFORD / BOSTON.
CT-15 N / WILBUR CROSS HWY becomes I-84 E (Portions toll).
Merge onto I-90 E / MASS PIKE / MASSACHUSETTS TURNPIKE toward N.H. - MAINE / BOSTON (Portions toll).
Take EXIT 18 on the LEFT toward CAMBRIDGE / SOMERVILLE.
Merge onto CAMBRIDGE ST.
CAMBRIDGE ST becomes RIVER ST / RIVER ST BRIDGE.
Turn RIGHT onto US-3 / MA-2 / MEMORIAL DR. Continue to follow MEMORIAL DR.
Turn SLIGHT LEFT onto MA-3 S / MEMORIAL DR.
Turn SLIGHT LEFT to take the ramp toward DOWNTOWN / GOV'T CENTER.
Turn RIGHT onto MA-3 S / MAIN ST. Continue to follow MA-3 S.
Turn LEFT onto CAMBRIDGE ST.
CAMBRIDGE ST becomes TREMONT ST.

The command just filters the results from this URL. I'm sure VB has an equivalent for each of those commands, but I'm not sure what they'd be. Maybe someone else can help you with that part.
 
Keep in mind that Mapquests data is actually licensed from other people and if you redistribute you are looking at a major copyright infringement suit. Be carefull
 
Oddly enough I wrote a program that does exactly this (in VB too), but it would also generate new HTML and retrieve the images and print it out for you. Here, its probably out dated but I'm sure you could work your way through the code and fix the parser:

http://idrive.sourceforge.net/

You can also download it on my site as well under the code section: http://www.ccorpsoft.com
 
Anything you write that scrapes text out of the HTML will be pretty fragile. That is, if MapQuest decides to change the format or presentation of the page, your application might break.

bofkentucky is right; if you are pulling data off the site, you have to worry about licensing issues.

You can solve both issues by using MapQuest's API to get the data you want.
 
By the way, I'm amused to find the TEAR sample that I wrote is still in MSDN and included in VC++. It will get the response from the server given a URL. Maybe, if you can't use the MapQuest API, you can use that code as a starting point.
 
Wow thanks to everyone. I'm gonna get started on trying all of these ideas and see what works. Thanks again.
 
Back
Top