|
-
Jun 15th, 2006, 06:13 AM
#1
Thread Starter
Fanatic Member
Shot in the dark... CASE RE-OPENED
This is a really vague question, so apologies to all you wunnerful people!
Company I work for has a shipment tracking website with a field where you pop in a shipment number, hit enter and another page pops up showing the various "milestones". Looks like I'm going to be tracking a number of these beasties in the future, so I'm wondering, is there anyway I could knock up a little VB app that would automatically submit the shipment numbers to the page and then grab the resulting info?
The page with the search field on ends ".asp" and the results page (which opens in another IE instance) ends with ".exe". Would the bit I stole from the search page below be of any use?
HTML Code:
<form ACTION="../Cgi-Bin/TSCGI.exe" METHOD="POST" NAME="TrackIT" TARGET="Result">
<tr>
<td width="50"></td>
<td ><H1> Package ID:</H1>
<input TYPE="text" SIZE="23" MAXLENGTH="20" NAME="ShipmentReference" />
<input class="button" TYPE="submit" NAME="Search" VALUE="Search" />
</td>
</tr>
</form>
Last edited by coox; Jun 30th, 2006 at 03:43 AM.
Nick Cook
VB6 (SP6)
-
Jun 15th, 2006, 06:55 AM
#2
PowerPoster
Re: Shot in the dark...
It looks like a simple enough thing to do...any amateur programmer could build the POST string to send through Inet, Winsock or (if you want to be lazy) webbrowser...then scan and parse the resulting text and output results to a textbox or listbox/listview
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 15th, 2006, 07:06 AM
#3
Re: Shot in the dark...
 Originally Posted by smUX
It looks like a simple enough thing to do...any amateur programmer could build the POST string to send through Inet, Winsock or (if you want to be lazy) webbrowser...then scan and parse the resulting text and output results to a textbox or listbox/listview
Then, perhaps, you could provide coox with an example.
-
Jun 15th, 2006, 08:01 AM
#4
Thread Starter
Fanatic Member
Re: Shot in the dark...
Ah, so it's possible then eh? Great! If you could give me any sample code at all that'd be a great help as I've not ventured down this path at all before.
Cheers!
Nick
-
Jun 15th, 2006, 09:00 AM
#5
Hyperactive Member
Re: Shot in the dark...
never done this before either, but active server pages use the URL get queries. though not ASP, google is a good example of this type of thing.
http://www.google.com/search?hl=en&q...=Google+Search
i searched for vb6, and clicked search. notice how my search term is in the url of the results page.
another example from IMDB: i searched for "free"
http://www.imdb.com/find?s=all&q=free
to automate this type of submission simply:
you need three strings:
1. the text left of the "?",= etc... ex:http://www.imdb.com/find?s=all&q=
2. your term. ex free
3. the paramaters, or text to the right of your term. (sometimes optional)
then just build a string to use as a url.
url= strLeft & strTerm & strRight
the you could open that url in webbrowser, use the DownloadURLtofile API function, sendkeys to firefox, etc to save the data.
if it is a secure site, this can be more complcated...
can you submit a search and post the resulting URL here?
i might be able to whip something up for you.
-
Jun 15th, 2006, 09:08 AM
#6
Thread Starter
Fanatic Member
Re: Shot in the dark...
Rnd,
Thanks, but it doesn't seem to work that way. See for yourself:
http://tracking.exel.com/tracking/sh..._tracking0.asp
Then enter this value: AMS02-00150412
See what I mean? Looks a bit complicated eh?
-
Jun 15th, 2006, 09:40 AM
#7
PowerPoster
Re: Shot in the dark...
 Originally Posted by coox
Not really, not to someone's who's been faffing around with POST and GET statements for years, like me :-)
Looking at the form at the URL you give, the correct URLto send would be http://tracking.exel.com/tracking/sh...&Search=Search ...Your mission, should you choose to accept it, is to now take that data OUT of the webpage...A suggestion to you would be to use SPLIT and split using "<TD " then work out at which point you need to collate data from (you also need to probably run a replace(origHTML,"NOWRAP>","") to remove that bit and the same with the "NOWRAP COLSPAN='2'>" and "</TD>" and all that should be left in each array would be the actual data. You COULD do this filtering before splitting the data and that would probably be more efficient (filter out the 3 strings from the HTML then split using "<TD " after.
It's a simple enough task, but you *did* ask "is there anyway I could knock up a little VB app" so I am not actually *writing* it for you, just giving you pointers...if you want something written totally, I can probably do it but can't guarantee you'll get it any time soon as I have my own projects to be working on :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 15th, 2006, 10:10 AM
#8
Thread Starter
Fanatic Member
Re: Shot in the dark...
smUX,
Thanks for replying, I'll have a go with that. I always was intending to write i myself, I quite enjoy parsing things, it's the whole rest of it that I'm new to! If you fancy posting any code up to the point where it somehow grabs the resulting page say, to the clipboard or whatever that'd be a great help. Otherwise I'll have a nose about...
Cheers!
-
Jun 15th, 2006, 10:24 AM
#9
Hyperactive Member
Re: Shot in the dark...
ok, using smux's url, i was able to "roll over" the packacke code at the end of the string, and it seemed to work.
ex:
http://tracking.exel.com/tracking/sh...&Search=Search
http://tracking.exel.com/tracking/sh...&Search=Search
since you like parsing, just make some way of parsing out that url, with the package id you need.
you could capture the resulting html page as a string with inet:
VB Code:
Dim temp As String
temp = inet1.OpenURL("http://tracking.exel.com/tracking/shipmentstatus/Cgi-Bin/TSCGI.exe?ShipmentReference=AMS02-00150413&Search=Search")
of, if you prefer a file:
VB Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Dim errCode As Long
errCode= URLDownloadToFile(0, "http://tracking.exel.com/tracking/shipmentstatus/Cgi-Bin/TSCGI.exe?ShipmentReference=AMS02-00150413&Search=Search", "c:\package1.htm", 0, 0)
you could substitute clipboard.settext for temp in the first example, if thats how you want it.
hope this helps.
-
Jun 15th, 2006, 10:31 AM
#10
PowerPoster
Re: Shot in the dark...
Easiest way is to use a webbrowser...I usually rename it to wb so when you see "wb" you know that is the name of the webbrowser...
First thing is to do wb.navigate "URLHERE" (don't forget to add a webbrowser component on your form...it doesn't have to be visible on the form but I believe it CAN'T be visible=false, I think that affects whether it downloads or not :-)...just make its top=-1000 and left=-1000 (and width/height being under 1000 :-)))
Now go to the code view, and there's two dropdowns...change the first to "WB" and second to "documentcomplete". In this area, put "HTML = wb.document.body.innerhtml" and this puts the HTML source into the variable HTML. All your other parsing/filtering code goes here after this line too :-)
You COULD use a "htm = split(HTML,"<TABLE")" to split the HTML to the point at which the table starts, then do the split I said earlier on htm(1) instead (htm(0) would be the data from the start to where the table starts, htm(1) is everything afterwards)
If you have any problems while coding, feel free to ask here...I'll probably be on. If you're having major problems coding it, pack up the code into a RAR/ZIP file and go to www.yousendit.com and post it there (they store the files for others to download...others YOU give a URL to)...give them any email address, doesn't even have to be valid, and NOTE the URL they give after it's uploaded...priv. message me it and I'll go through the code seeing if I can find the error and reply with the fixed code if possible (and also a note of the changes I made :-))
Alternatively publicly post it here if you don't mind other people seeing it...maybe they'll even have a go themselves :-)
If you decide to give up on it, post the partial code and I could probably complete it for you :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 15th, 2006, 10:35 AM
#11
Thread Starter
Fanatic Member
Re: Shot in the dark...
rndme - thanks for that, but what do I need to add to my project for inet1 to work? A reference or a component? And which one exactly? I think I'm very nearly there with this - thanks for all your help!!!
-
Jun 15th, 2006, 10:41 AM
#12
PowerPoster
Re: Shot in the dark...
Inet or Webbrowser are under project, components. Inet is "Microsoft internet transfer control" and Webbrowser is "Microsoft internet controls"
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 15th, 2006, 10:43 AM
#13
Thread Starter
Fanatic Member
Re: Shot in the dark...
Hehe, just found it myself. I'm just going to go with your code
Code:
Dim temp As String
temp = Inet1.OpenURL("http://tracking.exel.com/tracking/shipmentstatus/Cgi-Bin/TSCGI.exe?
ShipmentReference=AMS02-00150413&Search=Search")
...and rock on from there. This is cool! Thanks very much to all who partook in the production of this thread. I'd also like to thank my mother, the milkman, etc....
Last edited by Hack; Jun 15th, 2006 at 10:48 AM.
Nick Cook
VB6 (SP6)
-
Jun 15th, 2006, 10:54 AM
#14
PowerPoster
Re: Shot in the dark... RESOLVED
Does the reference ID ever change? If so, you could replace the URL with "http://tracking.exel.com/tracking/shipmentstatus/Cgi-Bin/TSCGI.exe?
ShipmentReference=" & trim(RefID) & "&Search=Search"
(trim trims spaces to the left and right of the ID...just in case :-))
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 15th, 2006, 11:05 AM
#15
Thread Starter
Fanatic Member
Re: Shot in the dark... RESOLVED
smUX, yep, I'll be using this to search for info on all sorts of shipments, so you're right of course, I'll need to insert the ref as you've indicated above. Thanks!
-
Jun 15th, 2006, 11:37 AM
#16
PowerPoster
Re: Shot in the dark... RESOLVED
You might also want to integrate a listbox or listview with a list of all the shipments you're tracking at a time...you could have textbox(es) at the bottom for the ability to add new tracking orders...and you could have an "update all" function that does each ID in the listbox/view easy enough :-)
Your choice about how you'd delete from the list...you could have it so clicking puts it into the "add" textbox you use to add new names and could also have an "update" and "delete" button next to the "add" button, or clicking deletes the name from the list (former is better, latter is faster to delete but also more prone to error when you delete something you don't want to delete) :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 30th, 2006, 03:40 AM
#17
Thread Starter
Fanatic Member
Re: Shot in the dark... CASE RE-OPENED
Sorry to bring this all up again. I got my previous app working perfectly, btw, so thanks again.
Anyway, the question is now - we have another site that I'd also like to automatically query, but this one seems to use the POST method instead of SUBMIT. This page is at http://sci2.exel.com
Once again, the parsing is no problem for me - it's the first dipping-the-toe-in-the-water when dealing with logins like this (and keep the subsequent pages logged in too I guess) that I've no experience of.
Hope this makes sense!
Cheers
-
Jun 30th, 2006, 10:51 AM
#18
Thread Starter
Fanatic Member
Re: Shot in the dark... CASE RE-OPENED
-
Jun 30th, 2006, 11:06 AM
#19
Re: Shot in the dark... CASE RE-OPENED
Whack!
lol...
hey, take a look at the webbrowser control tutorial on my website..
(link in my sig)
in this case u will need:
username
userpassword
and using the webbrowser control (Or just the HTML object...)
you can fill out the forms and parse the data back in
one note: a submit image is used...
so u wont be able to just submit.click... you will need to loop thru inputs and click it when found.. I would use the alt tag ("submit")
i have a sample on my site how to do something very similar
if u still get stuck.. let me know
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 18th, 2006, 05:16 AM
#20
Thread Starter
Fanatic Member
Re: Shot in the dark... CASE RE-OPENED
Ok, so thanks to you guys, I got a very neat little app working that grabs all sorts of info. My boss loves it, but... just when I got it working, they decided to switch everything to a new site.
https://interactive1.dhl.com/TrackRe...ller/anontrack
I've been faffing around for a while now, trying to figure out how to get the correct URL to query, but I'm stuck. Anyone got any ideas?
-
Dec 19th, 2006, 05:47 AM
#21
Thread Starter
Fanatic Member
Re: Shot in the dark... CASE RE-OPENED
Bump!
I'll lose my no-claims bonus if I keep bumping like this...
-
Dec 24th, 2006, 03:40 AM
#22
New Member
Re: Shot in the dark... CASE RE-OPENED
Code:
https://interactive1.dhl.com/TrackReport/controller/AnonShipmentTracking?SearchType=HBN&SearchValue=AMS02-00150412
Dunno if it will work from code but it works if firefox 
P.S. i would test it but i only have .net 2005 installed and i am not sure how differently it may/may-not handle the "https"...
anyway good luck
-
Dec 24th, 2006, 09:04 AM
#23
Thread Starter
Fanatic Member
Re: Shot in the dark... CASE RE-OPENED
Vyper, thanks very much for replying, much appreciated. That does work, and I've programmed it up accordingly - you're a star!
-
Dec 24th, 2006, 06:28 PM
#24
New Member
Re: Shot in the dark... CASE RE-OPENED
no prob, glad it worked for you.
-
Dec 24th, 2006, 08:58 PM
#25
New Member
Re: Shot in the dark... CASE RE-OPENED
Code:
Module Module1
Sub Main()
Dim WebRetr As New System.Net.WebClient
WebRetr.DownloadFile("https://interactive1.dhl.com/TrackReport/controller/AnonShipmentTracking?SearchType=HBN&SearchValue=AMS02-00150412", "c:\lookup\AMS02-00150412.html")
End Sub
End Module
Here is a quick an dirty vb.net console app for the same purpose - though in a real situation one would either take the tracking info from either command-line or better yet getting it from a SQL Query...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|