Jump to content
Sign in to follow this  
Symplystyc

Need someone to tell me why this isnt working

Recommended Posts

Symplystyc

$oIE = _IE_Example ("basic")
$file = FileOpen("test.txt", 1)
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
FileWrite("test.txt",$oLinks)
FileClose($file)

I thought this would open a text file and write all of the links from a given webpage on it. All I get is an empy text file.


The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Generator

$oIE = _IE_Example ("basic")
$file = FileOpen("test.txt", 1)
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $oLink In $oLinks
   FileWrite("test.txt",$oLink.herf & @CRLF)
Next
FileClose($file)

Share this post


Link to post
Share on other sites
Symplystyc

When I run that I get errors at the & sign. If I remove the & @CRLF I get errors at the last )

If I remove the .herf after that I get no errors but an empty text file.


The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Generator

Sorry, it was a typo, change herf to href

Share this post


Link to post
Share on other sites
Symplystyc

Sorry, it was a typo, change herf to href

thank you very much.


The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Symplystyc

New question

When I do this

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php?showforum=2")
WinSetState("", "", @SW_MAXIMIZE)
fileopen = ("test.txt",1)
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $oLink In $oLinks
    If StringInStr($oLink.href,"http://www.autoitscript.com/forum/index.php?showtopic=") Then FileWrite("test.txt",$oLink.href & @CRLF)
Next

I can open the text file test.txt and see a list of all the links on that page that contain http://www.autoitscript.com/forum/index.php?showtopic=

Now when I do

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php?showforum=2")
WinSetState("", "", @SW_MAXIMIZE)
Dim $handle 
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $oLink In $oLinks
    If StringInStr($oLink.href,"http://www.autoitscript.com/forum/index.php?showtopic=") Then FileWrite($handle,$oLink.href & @CRLF)
Next

MsgBox( 4096,"",Ubound($handle))

I know this is wrong but I'm not sure what command to use for instead of Filewrite.

I then want to make a For loop that will go through each link in the $handle variable and click it. Once its clicked i have the rest of the script done. (I think)


The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Generator

Not sure if this is what you wanted...

#include <IE.au3>
Dim $Handle[1024], $Counter=0
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php?showforum=2")
WinSetState("", "", @SW_MAXIMIZE)
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $oLink In $oLinks
    If StringInStr($oLink.href,"http://www.autoitscript.com/forum/index.php?showtopic=") Then
        $Handle[$Counter]=$oLink.href
        $Counter+=1
    EndIf
Next
For $i=0 to UBound($Handle)
    _IENavigate($oIE,$Handle[$i],1)
Next

Share this post


Link to post
Share on other sites
Symplystyc

Neither am I. but this is what I did

#include <IE.au3>
#include <File.au3>

$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php?showforum=2")
WinSetState("", "", @SW_MAXIMIZE)
Dim $handle
FileOpen("test.txt",1)
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $oLink In $oLinks
    If StringInStr($oLink.href,"http://www.autoitscript.com/forum/index.php?showtopic=") Then FileWrite("test.txt",$oLink.href & @CRLF)
Next
_FileReadToArray("test.txt",$handle)

FileClose("test.txt")

so now I have the array $handle

If I wanted to use

$array = StringSplit($handle, " ")

what would I put as the delimiters?

Im not sure how the function _FileReadToArray takes a text file like

http://forums.d2jsp.org/index.php?showuser=230548
http://forums.d2jsp.org/index.php?showuser=212380
http://forums.d2jsp.org/index.php?showuser=162399
http://forums.d2jsp.org/index.php?showuser=233122
http://forums.d2jsp.org/index.php?showuser=278748
http://forums.d2jsp.org/index.php?showuser=299656
http://forums.d2jsp.org/index.php?showuser=356621

and writes it as an array. I think if I knew what the delimiters were in this array I could carry on for a day or so without asking any more questions.

Edited by Symplystyc

The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Generator

I do think the _FileReadToArray put them into elements, so try _ArrayDisplay() or Msgbox(0,"",$handle[0])

Share this post


Link to post
Share on other sites
Symplystyc

I do think the _FileReadToArray put them into elements, so try _ArrayDisplay() or Msgbox(0,"",$handle[0])

Oh very nice. I dont need to use StringSplit().

The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Symplystyc

okay last question of the night. I need to now press the send button

<input type="submit" value="Send Message" tabindex="4" accesskey="s" class='forminput' name='submit' />

heres where I'm at

If $iInputSnd Then
    
            For $Send In $oFrmItm_Btn03; For each $Input found in the $oFrmItm_Btn01 collection,
                If $Send.type = "submit"  And $Send.name = "submit"  Then; if they match the following criteria
                    
; inputs message title
                    $binFlag = True; set the flag
                    ExitLoop; and bail out of the loop
                EndIf
            Next
EndIf

Got the If but I'm not sure what the Then is.


The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
Share on other sites
Symplystyc

Once again, Thank You.


The glass is neither half empty nor half full, it is simply twice as big as it needs to be.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.