MrJoshC Posted October 10, 2012 Share Posted October 10, 2012 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> <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 More sharing options...
FireFox Posted October 10, 2012 Share Posted October 10, 2012 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 More sharing options...
MrJoshC Posted October 11, 2012 Author Share Posted October 11, 2012 (edited) 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 October 11, 2012 by MrJoshC Link to comment Share on other sites More sharing options...
jdelaney Posted October 11, 2012 Share Posted October 11, 2012 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. Link to comment Share on other sites More sharing options...
FireFox Posted October 11, 2012 Share Posted October 11, 2012 Check the source code returned by the function _INetGetSource, the quotes can be HTML encoded or there might be some spaces. Br, FireFox. Link to comment Share on other sites More sharing options...
MrJoshC Posted October 11, 2012 Author Share Posted October 11, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now