allSystemsGo Posted September 12, 2013 Share Posted September 12, 2013 (edited) I've been working on this for a while now and I still cannot seem to wrap my head around it. I want to pull this info: <div id="storeList0" class="rec first"> <div class="recH"><a class="storeName" href="index.jsp?store=04923&saddr=37.3346228,-87.48020680000002(42431)&daddr=37.520247,-87.113696(667%20US%20Highway%20431%20N%20Livermore,%20KY%2042352)"> … </a><div class="miles"> 24 miles </div><div class="address"> 667 US Highway 431 N <br></br> Livermore, KY 42352 </div><div class="phoneNumber"> 270.278.2816 </div> From this website: http://www.acehardware.com/mystore/storeLocator.jsp#42431|50 I'd like to take that info and put it into either a txt file or a CSV file. So far, from what I've read around the forum I have this code: expandcollapse popupFunc aceData() $fIni = "c:\temp\zip.ini" Global $count =500 $zip = IniRead($fIni, "Zip", $count, "NotFound") $url = "http://www.acehardware.com/mystore/storeLocator.jsp#"&$zip&"|50" Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Global $oIE = _IECreateEmbedded() GUICreate("Ace Hardware Data Grabber", 1920, 1080, _ (@DesktopWidth - 1920) / 2, (@DesktopHeight - 1080) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 900, 750) GUISetState() ;Show GUI _IENavigate($oIE, $url) _IELoadWait($oIE,"5",'') _IEPropertySet($oIE,"silent","true") $checksum1=PixelChecksum(25,82,81,24,'',$oIE,'') Do sleep(500) _IELoadWait($oIE,"5",'') _IEPropertySet($oIE,"silent","true") $iForm=_IEFormGetObjByName($oIE,"frm") $iQuery=_IEFormElementGetObjByName($iForm,"fldAddress") $iZip=_IEFormElementSetValue($iQuery,$zip) $iRadius=_IEFormElementGetObjByName($iForm,"fldRadius") _IEFormElementOptionSelect($iRadius,"50") $stores=_IETagNameGetCollection($oIE,"div") For $store in $stores Local $storeinfo=$stores.getAttribute("recH") MsgBox(64,"what",$storeinfo) Next $iSearch= _IEGetObjById($oIE,"searchBtn") _IEAction($iSearch,"click") _IELoadWait($oIE,"5",'') _IEAction($oIE,"selectall") $aCopy=_IEAction($oIE,"copy") _IEAction($oIE,"unselect") $aData=_ClipBoard_GetData() $File="c:\temp\ace\ace"&$count&".txt" FileOpen($file,1) FileWrite($file,$aData) FileClose($file) Local $aArray _FileReadToArray($file,$aArray) _ArrayToClip($aArray) $bData=_ClipBoard_GetData() FileOpen($file,2) $text= _FileWriteFromArray($file,$aArray,165) FileClose($file) sleep(500) $count= $count + 1 $zip = IniRead($fIni, "Zip", $count, "NotFound") Until $count=43630 EndFunc Where I was just navigating, copy, paste, throw into a file and move in. But that is not very sophisticated. How can I get this DIV stuff to work? Any tips or ideas are appreciated! Oh and I get this error: C:UsersuserDesktopAutoIT_Scriptscratch.au3 (64) : ==> The requested action with this object has failed.: Local $storeinfo=$stores.getAttribute("recH") Local $storeinfo=$stores.getAttribute("recH")^ ERROR ->10:55:04 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 5.277 Edited September 12, 2013 by allSystemsGo Link to comment Share on other sites More sharing options...
Valuater Posted September 12, 2013 Share Posted September 12, 2013 Give this a try... code is included I just ran your site and it worked great!! '?do=embed' frameborder='0' data-embedContent>> 8) Link to comment Share on other sites More sharing options...
allSystemsGo Posted September 12, 2013 Author Share Posted September 12, 2013 Can you elaborate? I am not seeing how this will help me other than breaking down the source code, which is helpful. Link to comment Share on other sites More sharing options...
allSystemsGo Posted September 12, 2013 Author Share Posted September 12, 2013 Im thinking this finds the what I am looking for... $stores=_IETagNameGetCollection($oIE,"a") For $store in $stores If String($store.className)="storeName" Then Msgbox(64,"what",$store.getAttribute) EndIf Next but how would I get the actual store name to show up in MsgBox? Link to comment Share on other sites More sharing options...
allSystemsGo Posted September 12, 2013 Author Share Posted September 12, 2013 So i can pull the data now... $stores=_IETagNameGetCollection($oIE,"a") $divs=_IETagNameGetCollection($oIE,"div") For $store in $stores If String($store.className)="storeName" Then Msgbox(64,"what",_IEPropertyGet($store,"innertext") & @CRLF) Endif Next For $address in $divs If String($address.className)="address" Then MsgBox(64,"aw geez",_IEPropertyGet($address,"innertext") & @CRLF) Endif Next For $phone in $divs If String($phone.className)="phoneNumber" Then MsgBox(64,"no way",_IEPropertyGet($phone,"innertext") & @CRLF) EndIf Next Link to comment Share on other sites More sharing options...
allSystemsGo Posted September 12, 2013 Author Share Posted September 12, 2013 Is FOR...NEXT the best way to do this? I would like to format my document so that the store name, address, and phone number all match up. This method writes Store1, Store2, address1, address2, etc. 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