Jump to content

Recommended Posts

Posted (edited)
#include <IE.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <ArrayDisplayInternals.au3>
#include <InetConstants.au3>
#include <WinAPI.au3>
#include <WinAPIsysinfoConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <Inet.au3>
#include <File.au3>
#include <Date.au3>
#include <Misc.au3>
#include <Debug.au3>


Local $ProductName
Local Const $ie_newtab = 0x0800
Local $arr[30]


$oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A")
_IELoadWait($oIE, 1, 1)

$sHtmlpag = _IEBodyReadHTML($oIE)

Local $oInputs = _IETagNameGetCollection($oIE, "a")

Local $array = StringRegExp($sHtmlpag, "More information", $STR_REGEXPARRAYGLOBALMATCH)

MsgBox($MB_SYSTEMMODAL, "Product Name", $array)

_ArrayDisplay($array)


    For $i=0 To UBound ($array) -1
        For $oInput In $oInputs
            if $oInput.title = "More information" then
                Local $oIELink = $oInputs
                $oIE.Navigate($oinput.href, $ie_newtab)
                MsgBox($MB_SYSTEMMODAL, "Product Name", $oinput.href)
                _IELoadWait($oIE)
            ExitLoop
            endif

        Next

        MsgBox($MB_SYSTEMMODAL, "Chains and Accessories", $oIELink.title)

        Send("^w")
        Sleep(3000)

    Next
    


Func Terminate()
    Exit 0

EndFunc   ;==>Terminate

@faustf, Bundle of thanks for diverting me to on ARRAY, in the above shared code please note that it is showing all the hyperlinks with Title ="More information" collected in the array & only one first array is opening in new tab. after closing the tab the script is terminated and the script next to second-loop is not working.

 

<a title="More information" href="productinfo.htm?orgid=WKTL 150">WKTL 150</a>

<img style="vertical-align: middle;" src="images/information38.png">    ----------> this image is also have title = "More Information"

 

Above code is displaying me the both <a> & <img> in array   but i need to work only on <a>

 

I need to open & close all the href's one by one (other process for what to do with the opened tabs.... I have already completed that script) :) 

 

 

 

 

Edited by Imranimi
Posted (edited)
32 minutes ago, Imranimi said:

only one first array is opening in new tab.

Spoiler

Things that the user may find unpleasant:

Spoiler

Open your eyes.

 

Remove ExitLoop from the Loop then.

32 minutes ago, Imranimi said:

Above code is displaying me the both <a> & <img> in array   but i need to work only on <a>

Exclude img tags from your search loop.

Spoiler

Things that the user may find unpleasant:

Spoiler

This is because you're copy-pasting/asking for code since you're here and you'll never understand what your code does.

 


 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted (edited)
6 hours ago, FrancescoDiMuro said:
  Reveal hidden contents

Things that the user may find unpleasant:

  Reveal hidden contents

Open your eyes.

 

Remove ExitLoop from the Loop then.

Exclude img tags from your search loop.

  Reveal hidden contents

Things that the user may find unpleasant:

  Reveal hidden contents

This is because you're copy-pasting/asking for code since you're here and you'll never understand what your code does.

 


 

Remove ExitLoop from the Loop then.

 

 

Edited by faustf
Posted (edited)

@faustf Thanks for your pleasant feedback & pushing me to finish my script with all requirement (Oh thanks for the hidden comments, it really helped me to examine/see my script carefully) ;) 

Can you give me a hint to filter img-tag in search loop. 

Really, you had helped me alot to close my script, Thanks a lot :) 

Edited by Imranimi
Posted (edited)

your  regexp is   modify,    this  part  probably not match nothing 

 "(.*?)" </a>'

because  "  " in your html  suppose not exist  because if  you  want catch  wktl 150 simply  (.*?)

 WKTL 150 </a>', 

i spoken  use regexp buddy and  find a correct regexp  for  your case  

is  difficult for me help  without a webpage ...try

Edited by faustf
Posted

What is the point of the array?  Its not used at all in the script posted above except for a loop?  If you wanted to capture the urls into an array you would just use the objects href as below:

#include <Array.au3>
#include <IE.au3>
Local $aMoreInfo[0]
Local Const $ie_newtab = 0x0800
Local $oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A")
_IELoadWait($oIE, 1, 1)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
If IsObj($oLinks) Then
    For $oLink In $oLinks
        If $oLink.title = "More information" Then
            $oIE.Navigate($oLink.href, $ie_newtab)
            _IELoadWait($oIE)
            _ArrayAdd($aMoreInfo, $oLink.href)
        EndIf
    Next
EndIf
_ArrayDisplay($aMoreInfo)

 

Posted
7 hours ago, Subz said:

What is the point of the array?  Its not used at all in the script posted above except for a loop?  If you wanted to capture the urls into an array you would just use the objects href as below:

#include <Array.au3>
#include <IE.au3>
Local $aMoreInfo[0]
Local Const $ie_newtab = 0x0800
Local $oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A")
_IELoadWait($oIE, 1, 1)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
If IsObj($oLinks) Then
    For $oLink In $oLinks
        If $oLink.title = "More information" Then
            $oIE.Navigate($oLink.href, $ie_newtab)
            _IELoadWait($oIE)
            _ArrayAdd($aMoreInfo, $oLink.href)
        EndIf
    Next
EndIf
_ArrayDisplay($aMoreInfo)

 

Thanks a Ton :) but results are same for me as its showing url of both <a> & <img>

I need to filter one & play with it ;) 

i am doing r&d & will share the solution soon, if you have any idea just let me know.

 

Posted
8 hours ago, faustf said:

your  regexp is   modify,    this  part  probably not match nothing 


 "(.*?)" </a>'

because  "  " in your html  suppose not exist  because if  you  want catch  wktl 150 simply  (.*?)


 WKTL 150 </a>', 

i spoken  use regexp buddy and  find a correct regexp  for  your case  

is  difficult for me help  without a webpage ...try

I am trying to match & filter my required <a>

Posted

One & Last thing for this thread, Please provide some hint & help to solve.

 

How can i pick only one link when they are in array, as per guide by @faustf

 

 image.png.e22afa22e3063394a0ee541d8c85d025.png              1. Hypertext-Link

 

image.png.425e9927bc2e6a75e55d699add1d558b.png                                  2. Image-Link

 

 

@Subz your code is also give me the same result. 

For explanation:  The above links are of same product & in _ArrayDisplay() its showing me 2 products.

How can i play with only one link. below is the script-line which i am using ARRAY. :) 

 

...
....
.....

$sHtmlpag = _IEBodyReadHTML($oIE)

Local $oInputs = _IETagNameGetCollection($oIE, "a")

Local $array = StringRegExp($sHtmlpag, "More information", $STR_REGEXPARRAYGLOBALMATCH)

_ArrayDisplay($array)

...
....
.....

 

Autoit-Help Forum Guys are very much helpful & loving, they helped me a lot to complete my script (as i am a new bee).

Just show me a right way to solve above situation.

@Nine @faustf    @Subz   Thanks a ton, Cheers :)  

 

Posted

You just need to check the next tagname, the following will only navigate and add links to the array where the next tagname doesn't match <img...> tag.

#include <Array.au3>
#include <IE.au3>
Local $aMoreInfo[0]
Local Const $ie_newtab = 0x0800
Local $oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A", 1)
_IELoadWait($oIE, 1, 1)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
If IsObj($oLinks) Then
    For $oLink In $oLinks
        If $oLink.title = "More information" Then
            ;~ Check to see if next element is an <img...> tag
            If $oLink.NextElementSibling.tagName <> "img" Then
                $oIE.Navigate($oLink.href, $ie_newtab)
                _IELoadWait($oIE)
                _ArrayAdd($aMoreInfo, $oLink.href)
            EndIf
        EndIf
    Next
EndIf
_ArrayDisplay($aMoreInfo)

 

Posted
 ;~ Check to see if next element is an <img...> tag
            If $oLink.NextElementSibling.tagName <> "img" Then

 

The above code is not working as per my requirement & it's giving the same previous results..... ... (no change in result)

Posted (edited)

no, i am modifying it because i need to open the tabs one-by-one after pop-up message 

as your code is directly opening the tabs in one shot & making my PC & internet too much busy :( 

so now i am adding message-box script to give a break in loop.

 

Edited by Imranimi
Posted

Then just use the following to get the array:

#include <Array.au3>
#include <IE.au3>
Local $aMoreInfo[0]
Local Const $ie_newtab = 0x0800
Local $oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A", 1)
_IELoadWait($oIE, 1, 1)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
If IsObj($oLinks) Then
    For $oLink In $oLinks
        If $oLink.title = "More information" Then
            ;~ Check to see if next element is an <img...> tag
            If $oLink.NextElementSibling.tagName <> "img" Then
                _ArrayAdd($aMoreInfo, $oLink.href)
            EndIf
        EndIf
    Next
EndIf
_ArrayDisplay($aMoreInfo)

 

Posted

image.thumb.png.8f10b35b51f63ea4f78b9ac66ba274f2.png

yes, the results are same.... showing 908-items in array but actually they are half to this number (454-items) as in array they are coming in duplicate because the <a> & <img> links share before.

 

How can i bypass or filter 1st-array to 3rd then 5th  because it will save my time otherwise i have do one task for twice ..... 

Urgent help needed, thanks....  

   

Posted (edited)

Don't know why it's not working for you, but you can either use:

a. _ArrayUnique, to only show unique results (example in the code below.

Or

b. Just add unique links only

#include <Array.au3>
#include <IE.au3>
Local $aMoreInfo[0]
Local Const $ie_newtab = 0x0800
Local $oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A", 1)
_IELoadWait($oIE, 1, 1)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
If IsObj($oLinks) Then
    For $oLink In $oLinks
        If $oLink.title = "More information" Then
            If _ArraySearch($aMoreInfo, $oLink.href) = -1 Then _ArrayAdd($aMoreInfo, $oLink.href)
        EndIf
    Next
EndIf
_ArrayDisplay($aMoreInfo)
;~ Local $aUniqueLinks = _ArrayUnique($aMoreInfo)
;~ _ArrayDisplay($aUniqueLinks)

 

Edited by Subz

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
  • Recently Browsing   0 members

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