jxn Posted October 22, 2010 Share Posted October 22, 2010 Hi, I am trying to get product names and links from a website, but having trouble with the code: #include <IE.au3> $oIE = _IECreate("http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=towel&x=0&y=0") ;open a webpage in IE $sText = _IEBodyReadHTML ($oIE) ;-----------------Find product links and display them--------------- #include <String.au3> #include <Array.au3> $product = _StringBetween($sText, '<a class="title" href="', '">') _ArrayDisplay($product, 'Default Search') The problem is, in this case, I suppose I should be getting all the product links, with the first product link (link for Pike Street 725) in the first row, the second one in the second row, and so on. However, I only got three irrelevant product links. Is it because I didn’t get the page source correctly? I have no idea. Can someone help me figure it out, how to fix the problem? Many thanks! Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 22, 2010 Share Posted October 22, 2010 _IELinkGetCollection(). See example script in the help file. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jxn Posted October 25, 2010 Author Share Posted October 25, 2010 (edited) @PsaltyDS Thanks, the problem has been solved. I use _IELinkGetCollection()to get specific links, then use other methods to sort out duplicate links. Here is the revised code: #include <IE.au3> #Include <Array.au3> $oIE = _IECreate("http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=towel&x=0&y=0") ;open a webpage in IE $oLinks = _IELinkGetCollection ($oIE) $iNumLinks = @extended Global $Link_Array[$iNumLinks] For $oLink In $oLinks If StringInStr($oLink.href,"?ie=UTF8&qid=") Then _ArrayAdd($Link_Array,$oLink.href) EndIf Next _ArrayDisplay($Link_Array) Edited October 25, 2010 by jxn 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