Jump to content

what am I doing wrong?? (get object from IE browser)


Go to solution Solved by Danp2,

Recommended Posts

this is the text that i try to get:

<a class="js-nav" href="/followers" data-nav="followers" data-element-term="follower_stats" data-is-compact="false">  <strong title="985" class="js-mini-profile-stat">985</strong>
</a>

the only about the (dynamic) number 985

this is my script:

#include <Buttonconstants.au3>
#include <Editconstants.au3>
#include <Guiconstantsex.au3>
#include <staticConstants.au3>
#include <windowsConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <Excel.au3>
#include <ff.au3>
#include <Chrome.au3>

#Region ### START Koda GUI section ### Form=
$GUIT1 = GUICreate("Volger", 170, 193, 338, 185)
$Button3 = GUICtrlCreateButton("info", 8, 17, 145, 49)
$tekst3 = GUICtrlCreateEdit("", 8, 70, 145, 49)
GUICtrlSetData(-1, "")
$tekst4 = GUICtrlCreateEdit("", 6, 122, 148, 62)
GUICtrlSetData(-1, "followbacklist3")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$follwers = ("/followers")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button3


$link = GUICtrlRead($tekst4)

        $oIE = _IECreate("https://twitter.com/"&$link & $follwers)   

$oInput2s = _IETagNameGetCollection($oIE, "a")
For $oInput2 In $oInput2s
    If $oInput2.className() = "js-nav" Then
        If StringInStr($oInput2.innerHTML(), 'Volgers') Then
            ConsoleWrite(_StringBetween($oInput2.innerHTML(),'>','<')[0] & @CRLF)
            ExitLoop
        EndIf
    EndIf
Next

$numbvolgers = (_StringBetween($oInput2.innerHTML(),'>','<')[0] & @CRLF)

GUICtrlSetData($tekst3,""& $numbvolgers )


EndSwitch
WEnd

if i try to run it it shuts down and gives the error:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\pc\Desktop\autoit\teller.au3" /UserParams    
+>17:33:50 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>17:33:50 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\pc\Desktop\autoit\teller.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
"C:\Program Files (x86)\AutoIt3\Include\String.au3" (42) : ==> Subscript used on non-accessible variable.:
Func _StringBetween($sString, $sStart, $sEnd, $fCase = False)
Func _StringBetween($sString, $sStart, $sEnd, $fCase = False^ ERROR
->17:33:56 AutoIt3.exe ended.rc:1
+>17:33:56 AutoIt3Wrapper Finished..
>Exit code: 1    Time: 5.954

I have lookt it over and over again but I cannot find the issue

Link to comment
Share on other sites

You can also do something like this, rather than the stringbetween:

;~ Where html is:
;~ <HTML>
;~ <title>something</title>
;~ <BODY>
;~ <a href="google.com"><strong>50</strong></a>
;~ </BODY>
;~ </HTML>
$oIe = _IEAttach("something")
$oLinks = _IELinkGetCollection($oIe)
For $oLink In $oLinks
    If $oLink.childnodes.length > 0 Then
        ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
    EndIf
Next
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

 

You can also do something like this, rather than the stringbetween:

;~ Where html is:
;~ <HTML>
;~ <title>something</title>
;~ <BODY>
;~ <a href="google.com"><strong>50</strong></a>
;~ </BODY>
;~ </HTML>
$oIe = _IEAttach("something")
$oLinks = _IELinkGetCollection($oIe)
For $oLink In $oLinks
    If $oLink.childnodes.length > 0 Then
        ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
    EndIf
Next

 

I have read the help file under "_IEAttach"

and this is what I have tryed :

;~ Where html is:
;~ <HTML>
;~ <title>Followbacklist(@followbacklist3) op Twitter</title>
;~ <BODY>
;~ <a href="https://followbacklist/followers"><strong>50</strong></a>
;~ </BODY>
;~ </HTML>

#include <IE.au3>

$oIe = _IEAttach("js-nav","Followbacklist(@followbacklist3) op Twitter")
$oLinks = _IELinkGetCollection($oIe)
For $oLink In $oLinks
    If $oLink.childnodes.length > 0 Then
        ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
    EndIf
Next

MsgBox(0,"message","number:"&$oLinks) 

but it doesnt work , even the message box issent showing up:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:program" /UserParams    
+>16:01:06 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>16:01:06 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:program.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-1 Error from function _IEAttach, $_IEStatus_InvalidValue (Invalid Mode Specified)
--> IE.au3 T3.0-1 Error from function _IELinkGetCollection, $_IEStatus_InvalidDataType
"C:\Users\joesoef pc\Desktop\autoit\twitter programma\list.au3" (15) : ==> Variable must be of type "Object".:
For $oLink In $oLinks
For $oLink In $oLinks^ ERROR
->16:01:06 AutoIt3.exe ended.rc:1
+>16:01:06 AutoIt3Wrapper Finished..
>Exit code: 1    Time: 0.429
 

Could you please help me I think you understand more about this than I do

Link to comment
Share on other sites

Is the 'tab' on your browser = js-nav?  If not, then it won't attach, you won't get any links, and will fail when you attempt to itterate through them...because you are not doing any error checking.

If you are using the 'tab' to identify what to attach to, that's the 'title', which is the default 2nd param of IEattach, so you do not need to enter 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

Is the 'tab' on your browser = js-nav?  If not, then it won't attach, you won't get any links, and will fail when you attempt to itterate through them...because you are not doing any error checking.

If you are using the 'tab' to identify what to attach to, that's the 'title', which is the default 2nd param of IEattach, so you do not need to enter it.

ok i have corrected the title now i got:

;~ Where html is:
;~ <HTML>
;~ <title>Followbacklist(@followbacklist3) op Twitter</title>
;~ <BODY>
;~ <a href="https://followbacklist/followers"><strong>50</strong></a>
;~ </BODY>
;~ </HTML>

#include <IE.au3>

$oIe = _IEAttach("Followbacklist(@followbacklist3) op Twitter")
$oLinks = _IELinkGetCollection($oIe)
For $oLink In $oLinks
    If $oLink.childnodes.length > 0 Then
        ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
    EndIf
Next

MsgBox(0,"message","number:"&$oLinks)

the title of the tab = "Followbacklist(@followbacklist3) op Twitter"

I corrected what you said but it still doesn't work what am i doing wrong now?..I cant figure it out

Link to comment
Share on other sites

alright the error that i get is nomatter what i try

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\twitter programma.au3"/UserParams    
+>19:09:25 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>19:09:25 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\twitter programma.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-1 Warning from function _IEAttach, $_IEStatus_NoMatch
--> IE.au3 T3.0-1 Error from function _IELinkGetCollection, $_IEStatus_InvalidDataType
"C:\Users\joesoef pc\Desktop\autoit\twitter programma\teller2.au3" (16) : ==> Variable must be of type "Object".:
For $oLink In $oLinks
For $oLink In $oLinks^ ERROR
->19:09:25 AutoIt3.exe ended.rc:1
+>19:09:25 AutoIt3Wrapper Finished..
>Exit code: 1    Time: 0.425 

I am realy trying to understand it but english is not my first languages and I am really having a hard time to understand this.

the title of the tab = ""Followbacklist(@followbacklist3) op Twitter""

and the element that i try to get is : (number 985)

<a class="js-nav" href="/followers" data-nav="followers" data-element-term="follower_stats" data-is-compact="false">  <strong title="985" class="js-mini-profile-stat">985</strong>
</a>

please help me

Edited by Arclite86
Link to comment
Share on other sites

You need to add some error checking to your code. Once the call to _IEAttach fails (@error equals $_IEStatus_NoMatch), then it doesn't make sense to continue as if the error hasn't occurred.

_IEAttach defaults to looking for a substring of the title. Try running the following and post the results:

#include <IE.au3>

$oIe = _IEAttach("Followbacklist")

If @error = $_IEStatus_NoMatch Then
    ConsoleWrite("IE tab not found!" & @CRLF)
    Exit
EndIf

$oLinks = _IELinkGetCollection($oIe)

If @error = $_IEStatus_Success Then
    $linkCnt = @extended
    ConsoleWrite("Link count = " & $linkCnt & @CRLF)

    For $oLink In $oLinks
        If $oLink.childnodes.length > 0 Then
            ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
        EndIf
    Next
EndIf
Link to comment
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:twitter programma.au3" /UserParams    
+>20:12:27 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>20:12:27 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:twitter programma\.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-1 Warning from function _IEAttach, $_IEStatus_NoMatch
IE tab not found!
+>20:12:27 AutoIt3.exe ended.rc:0
+>20:12:27 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 0.432

it keeps saying IE tab not found! but the tab is called:"  Followbacklist (@followbacklist3) op Twitter" and i used it:

;~ Where html is:
;~ <HTML>
;~ <title> Followbacklist (@followbacklist3) op Twitter</title>
;~ <BODY>
;~ <a href="https://twitter.com/followbacklist3"><strong>50</strong></a>
;~ </BODY>
;~ </HTML>

#include <IE.au3>

$oIe = _IEAttach(" Followbacklist (@followbacklist3) op Twitter")

If @error = $_IEStatus_NoMatch Then
    ConsoleWrite("IE tab not found!" & @CRLF)
    Exit
EndIf

$oLinks = _IELinkGetCollection($oIe)

If @error = $_IEStatus_Success Then
    $linkCnt = @extended
    ConsoleWrite("Link count = " & $linkCnt & @CRLF)

    For $oLink In $oLinks
        If $oLink.childnodes.length > 0 Then
            ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
        EndIf
    Next
EndIf

MsgBox (0,"message","number:"&$oLinks)

(if I use "_IEAttach("Followbacklist")"  it give's the same error

Link to comment
Share on other sites

If I open an IE tab to https://twitter.com/followbacklist3 and then run the previous code that I posted, the script runs as expected.

With your posted code, this line fails:

$oIe = _IEAttach(" Followbacklist (@followbacklist3) op Twitter")

There are 3 issues: leading space, @ symbol, and 'op' vs 'on'. Making these corrections and this lines attaches properly:

$oIe = _IEAttach("Followbacklist (followbacklist3) on Twitter")
Link to comment
Share on other sites

 

If I open an IE tab to https://twitter.com/followbacklist3 and then run the previous code that I posted, the script runs as expected.

With your posted code, this line fails:

$oIe = _IEAttach(" Followbacklist (@followbacklist3) op Twitter")

There are 3 issues: leading space, @ symbol, and 'op' vs 'on'. Making these corrections and this lines attaches properly:

$oIe = _IEAttach("Followbacklist (followbacklist3) on Twitter")

op =  dutch for on ^_^

but if i open a the IE browser and go to the link,

and use: $oIe = _IEAttach("Followbacklist (followbacklist3) on Twitter")

or $oIe = _IEAttach("Followbacklist (followbacklist3) op Twitter")

i get the error:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:teller2.au3" /UserParams    
+>21:27:02 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>21:27:02 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:teller2.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-1 Warning from function _IEAttach, $_IEStatus_NoMatch
IE tab not found!
+>21:27:03 AutoIt3.exe ended.rc:0
+>21:27:03 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 0.420
Link to comment
Share on other sites

IDK. Have you tried using _IEAttach with a different web site? Or perhaps using the URL instead of the title?

i found out that it works if I use "twitter" https://twitter.com/followbacklist3  now i have got the tab and it gives a link count of- 327 how can i get the following number?

<a class="js-nav" href="/followers" data-nav="followers" data-element-term="follower_stats" data-is-compact="false">  <strong title="985" class="js-mini-profile-stat">985</strong>
</a>
Edited by Arclite86
Link to comment
Share on other sites

this is what i tried

#include <IE.au3>

$oIe = _IEAttach("Twitter")

If @error = $_IEStatus_NoMatch Then
    ConsoleWrite("kan niet gevonden worden" & @CRLF)
    Exit
EndIf



If @error = $_IEStatus_Success Then
    $linkCnt = @extended
    ConsoleWrite("Link count = " & $linkCnt & @CRLF)


$oLinks = _IELinkGetCollection($oIe)
    For $oLink In $oLinks
        If $oLink.childnodes.length > 0 Then
            ConsoleWrite($oLink.childnodes.item(0).innertext & @CRLF)
        EndIf
    Next
EndIf

MsgBox (0,"message","number:"&$oLinks )

in the "console" i see some info but it not focused on the number that i want:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\joesoef pc\Desktop\autoit\twitter programma\teller2.au3" /UserParams    
+>14:09:14 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>14:09:14 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\joesoef pc\Desktop\autoit\twitter programma\teller2.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Link count = 0











28
1.363




Geovana Siilva
anderen































GTA5tipsandtricks
CAKE LE PAINT
Dutch Goon ??

22 mrt.
#










7 min.
#
#
#
0








7 min.
0








7 min.







FollowMeJustinPls ?

17 u
@
0








7 min.
#
#
#
#
#
#
#
0








7 min.
0







FollowMeJustinPls ?

20 u
0







Jason

12 min.
#
0












7 min.
0
#
0








7 min.
#
0









7 min.
0








7 min.
#
#
0








7 min.
0








7 min.
#
#
#
0







? ???? 

20 u







FollowMeJustinPls ?

9 u
0







? ???? 

12 u
#











? ???? 

11 u
#











? ???? 

51 min.







? ???? 

11 u
#































+>14:09:17 AutoIt3.exe ended.rc:0
+>14:09:17 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 3.191

so could somebody help me with focusing on:

<a class="js-nav" href="/followers" data-nav="followers" data-element-term="follower_stats" data-is-compact="false">  <strong title="985" class="js-mini-profile-stat">985</strong>
</a>
Link to comment
Share on other sites

You need to locate the correct link by checking it's properties. Here's one way to do it:

#include <IE.au3>

$oIe = _IEAttach("Followbacklist (followbacklist3) on Twitter")

If @error = $_IEStatus_NoMatch Then
    ConsoleWrite("IE tab not found!" & @CRLF)
    Exit
EndIf

$oLinks = _IELinkGetCollection($oIe)

If @error = $_IEStatus_Success Then
    $linkCnt = @extended
    ConsoleWrite("Link count = " & $linkCnt & @CRLF)

    For $oLink In $oLinks
        If $oLink.className = 'js-nav' Then
            If $oLink.getAttribute('data-nav') = 'followers' Then
                ConsoleWrite('Followers = ' & $oLink.innerText & @CRLF)
            EndIf
        EndIf
    Next
EndIf
Link to comment
Share on other sites

 

You need to locate the correct link by checking it's properties. Here's one way to do it:

#include <IE.au3>

$oIe = _IEAttach("Followbacklist (followbacklist3) on Twitter")

If @error = $_IEStatus_NoMatch Then
    ConsoleWrite("IE tab not found!" & @CRLF)
    Exit
EndIf

$oLinks = _IELinkGetCollection($oIe)

If @error = $_IEStatus_Success Then
    $linkCnt = @extended
    ConsoleWrite("Link count = " & $linkCnt & @CRLF)

    For $oLink In $oLinks
        If $oLink.className = 'js-nav' Then
            If $oLink.getAttribute('data-nav') = 'followers' Then
                ConsoleWrite('Followers = ' & $oLink.innerText & @CRLF)
            EndIf
        EndIf
    Next
EndIf

thank you so much it worked!  :D

but one last question how can i get this to show in a messagebox I tried: "MsgBox (0,"message","number:"&$oLink)" but it doesnt work, I see it only in the console.

Link to comment
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
 Share

  • Recently Browsing   0 members

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