Jump to content

How do I grab specific data from IE source code?


MrJoshC
 Share

Recommended Posts

Just want to let everyone know before we start that I'm pretty raw to auto-it, I understand (some of) the basic functions but am self taught up to this point... So thanks for the help in advance!

Here is my situation; I would like to grab shipping tracking numbers that are located on a webpage without having to create a manual click & copy. There are several reasons why, but the main ones are that they aren't always located in the same spot on the page and sometimes those particular items haven't shipped yet.

I'm not sure how I would actually grab that data from within the element. An example of the source code is:

<b>with Tracking #</b>&nbsp;<a href="javascript:showTrackUrl('http://wwwapps.ups.com/etracking/tracking.cgi?tracknums_displayed=5&TypeOfInquiryNumber=T&HTMLVersion=4.0&InquiryNumber1=1Z86V8030334218266')" class="nrml_11_ul">1Z86V8030334218266</a>

All I need is the tracking number at the end (red). It would be great if someone could at least tell me if what I want to do is easily attainable and what functions would be useful. Let me know if you need more info.

Thanks again!

Josh

Link to comment
Share on other sites

Hi,

Welcome to the autoit forum :)

The first step is to retreive the source code of the webpage (with _INetGetSource func or IE funcs)

Then you can get all items by this way :

#include <Array.au3> ;just to display results
#include <String.au3>

$aTrackItems = _StringBetween($sourcecode, 'class="nrml_11_ul">', "</a>")

_ArrayDisplay($aTrackItems)

Br, FireFox.

Link to comment
Share on other sites

Thanks FireFox! That is incredibly useful. However, I'm still have an issue with it grabbing that data. I've tested the function and it works with other parts of the source code from the same page. But it doesn't return any values when I try and grab the tracking number.

To me it seems like the _stringbetween function doesn't read the code within the hyperlink element? I might be way off, but does anyone have some ideas?

Edit: Another thought, perhaps the code _inetgetsource is reading different code then what I get when I click "view source" on the webpage?

My code so far:

#include <Inet.au3>
#include <Array.au3>
#include <String.au3>


$sourcecode = _INetGetSource('website-here')
$aTrackItems = _StringBetween($sourcecode, 'class="nrml_11_ul">', '</a>')
_ArrayDisplay($aTrackItems, 'Results')
Edited by MrJoshC
Link to comment
Share on other sites

Thanks fellas! Turns out my problem was that when I tried to get the source it was pulling from the hosts log in page instead of the page I wanted. Looks like I have this portion figured out and now I get to start experimenting with the rest.

Thanks again for ideas, you guys rock.

~Josh

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...