Jump to content
Sign in to follow this  
MrJoshC

How do I grab specific data from IE source code?

Recommended Posts

MrJoshC

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

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
MrJoshC

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

Share this post


Link to post
Share on other sites
jdelaney

Use the _IE* functions. Attach to the browser, or create a hidden browser, and load your html into it.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
FireFox

Check the source code returned by the function _INetGetSource, the quotes can be HTML encoded or there might be some spaces.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
MrJoshC

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

Share this post


Link to post
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
Sign in to follow this  

×