Sign in to follow this  
Followers 0
tommytx

When using the For $oLink IN $oLinks how to grab the next line.

4 posts in this topic

#1 ·  Posted (edited)

I would appreciate some help with this.  The for loop searches  for the $find term and finds it with no problem

Howver what I want is to grab the first ID= following the line entry that has the correct file name which is "test-page-1"

So I need to grab the very next line so that I can extract the number following the id.. which is not a problem if I could identify how to print the next line.. As you can see I tried to add a 1 as $oLink+1.href to grab the next one but of course does not work.  Can anyone tell me the command to grab the next line folloiwng the find of the selected item.

 

Then grab the next line and extract the number 52960 following the id.

This way I can associate the file name "test-page-1" with the id "52960

I cannot searh for the IP since I don't know the ip until I find the line above the line with the id.

What it is searching thru.
**************************










$find = "test-page-1"

For $oLink IN $oLinks
   if StringInStr($oLink.href, $find) then 
      Consolewrite($oLink.href & @CRLF)
      Consolewrite($oLink+1.href & @CRLF)
   EndIf
Next
Edited by tommytx

Share this post


Link to post
Share on other sites



Maybe something similar.

$find = "test-page-1"
$next = 0
For $oLink In $oLinks
    If StringInStr($oLink.href, $find) Then
        If $next Then
            ConsoleWrite($oLink.href & @CRLF)
            ExitLoop
        Else
            $next = 1
        EndIf
    EndIf
Next
1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Wow! Thanks... I could not get your version to work for me but you put the idea in my brain as to how to run the loop and print the next one..

So this one will print the line that it finds and then run the loop once more and print the next line before quitting... Not sure why I could not get your version to work.. but you are a lifesaver as I would never have thougth to do it the way you suggested.. but what the hell it works great.

I tried to send some sample code with it, but even using hxxp the system thought i was trying to spam...and stopped it... Thanks again.

$find = "test-page-1"
   $next = 0

For $oLink In $oLinks
      If $next Then
         ConsoleWrite($oLink.href & @CRLF)
         ExitLoop
      EndIf
      
`    If stringinstring($oLink.href, $find) Then
      ConsoleWrite($oLink.href & @CRLF)
      $next = 1
   EndIf
   
Next
Edited by tommytx

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  
Followers 0