Jump to content

Retrieve xtring from Google Search results


Recommended Posts

how can I use the StringRegEx function to extract certain lines of text from google search results in the following format:

C: server port user password

an example is this:

C: starteam.myftp.org 18000 test1 text2

regards

 

Link to post
Share on other sites
#include <String.au3>
#include <Array.au3>
Global $sString = "C: starteam.myftp.org 18000 test1 text2"
Global $aSplit = StringSplit($sString, " ", $STR_NOCOUNT)
Global $aDisplay[0][0]

If (UBound($aSplit) = 5) Then
    ; This is just to make the _ArrayDisplay look good
    ReDim $aDisplay[UBound($aSplit)][2]

    $aDisplay[0][1] = $aSplit[0]
    $aDisplay[1][1] = $aSplit[1]
    $aDisplay[1][0] = "Server = "
    $aDisplay[2][1] = $aSplit[2]
    $aDisplay[2][0] = "Port = "
    $aDisplay[3][1] = $aSplit[3]
    $aDisplay[3][0] = "User = "
    $aDisplay[4][1] = $aSplit[4]
    $aDisplay[4][0] = "Password = "

    _ArrayDisplay($aDisplay)
EndIf

 

Link to post
Share on other sites
3 hours ago, InunoTaishou said:
#include <String.au3>
#include <Array.au3>
Global $sString = "C: starteam.myftp.org 18000 test1 text2"
Global $aSplit = StringSplit($sString, " ", $STR_NOCOUNT)
Global $aDisplay[0][0]

If (UBound($aSplit) = 5) Then
    ; This is just to make the _ArrayDisplay look good
    ReDim $aDisplay[UBound($aSplit)][2]

    $aDisplay[0][1] = $aSplit[0]
    $aDisplay[1][1] = $aSplit[1]
    $aDisplay[1][0] = "Server = "
    $aDisplay[2][1] = $aSplit[2]
    $aDisplay[2][0] = "Port = "
    $aDisplay[3][1] = $aSplit[3]
    $aDisplay[3][0] = "User = "
    $aDisplay[4][1] = $aSplit[4]
    $aDisplay[4][0] = "Password = "

    _ArrayDisplay($aDisplay)
EndIf

 

Thanks..

this is fine. but I' looking for a way to run and parse google search results for the full line in this format

C: starteam.myftp.org 18000 test1 text2

 

regards

 

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

    No registered users viewing this page.

  • Similar Content

    • By FrancescoDiMuro
      Good morning
      I'm playing with SRE and trying to obtain some information from a test file.
      I was testing the pattern on regex101, but when I bring it to AutoIt, it doesn't return the same result as on regex101.
      I am surely (?:missing some important notes about PCRE engine|the pattern is not correct at all).
      Script:
      #include <Array.au3> #include <StringConstants.au3> Test() Func Test() Local $strFileName = @ScriptDir & "\TestFile.txt", _ $strFileContent, _ $arrResult $strFileContent = FileRead($strFileName) If @error Then Return ConsoleWrite("FileRead ERR: " & @error & @CRLF) $arrResult = StringRegExp($strFileContent, '(?sx)User:\h([^\n]+)\n' & _ 'Login\-name:\h([^\n]+)\n' & _ '(?:CaseSensitive:\h([^\n]+)\n)?' & _ 'NTSecurity:\h([^\n]+)\n' & _ '(?:NO\n)?' & _ '(?:Domain:\h([^\n]+)\n)?' & _ 'Timeout:\h([^\n]+)\n' & _ '.*?' & _ 'Member:\h([^\n]+)\n', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then _ArrayDisplay($arrResult) EndFunc Test file:
      User: AMMINISTRATORE Login-name: ADM CaseSensitive: YES NTSecurity: NO NO Timeout: 00:05:00 Member: AMMINISTRATORI User: Test_User Login-name: Test_User NTSecurity: YES Domain: DNEU Timeout: 00:00:00 Member: OPERATORS Member: OPERATORS Any help (even from cats) it's highly appreciated.

      Cheers
    • By jmp
      i am trying to get number from string using this code :
      #include <IE.au3> $oIE = _IEAttach ("Edu.corner") Local $aName = "Student name & Code:", $iaName = "0" Local $oTds = _IETagNameGetCollection($oIE, "td") For $oTd In $oTds If $oTd.InnerText = $aName Then $iaName = $oTd.NextElementSibling.InnerText $iGet = StringRegExpReplace($iaName, "\D", "") EndIf Next MsgBox(0, "", $iGet) it was get number like 52503058
      But, I want to get only student code 5250. (Different student have different code, sometime its 3 digits, Sometime 4)

       
    • By BlueBandana
      Is there a way to output the regex matches into a file?
      I have a script to compare two files and check for regex matches.
      I want to output the matching regex of 'testexample.txt' to another file.
      #include <MsgBoxConstants.au3> #include <Array.au3> $Read = FileReadToArray("C:\Users\admin\Documents\testexample.txt") $Dictionary = FileReadToArray("C:\Users\admin\Documents\example.txt") For $p = 0 To UBound($Dictionary) - 1 Step 1 $pattern = $Dictionary[$p] For $i = 0 To UBound($Read) - 1 Step 1 $regex = $Read[$i] If StringRegExp($regex, $pattern, 0) Then MsgBox(0, "ResultsPass", "The string is in the file, highlighted strings: " ) Else MsgBox(0, "ResultsFail", "The string isn't in the file.") EndIf Next Next  
    • By therks
      So I have this pattern: 
      ^(?:(\d+)|(\d+):(\d+)|(\d+):(\d+):(\d+))$ And I'm expecting (depending on input) to get a 1, 2 or 3 index array (or @error for invalid input).
      But instead I get this:
      #include <Debug.au3> Func Test($String) _DebugArrayDisplay(StringRegExp($String, '^(?:(\d+)|(\d+):(\d+)|(\d+):(\d+):(\d+))$', 1)) EndFunc Test('10') ; Results (normal, expected): ; Row 0|10 Test('10:20') ; Results (extra blank index): ; Row 0| ; Row 1|10 ; Row 2|20 Test('10:20:30') ; Results (three blank indices): ; Row 0| ; Row 1| ; Row 2| ; Row 3|10 ; Row 4|20 ; Row 5|30 Is this normal? Should I just code around it, or is there a better way to do what I'm looking for?
      I also tried reversing my regex, but it was even uglier results:
      #include <Debug.au3> Func Test($String) _DebugArrayDisplay(StringRegExp($String, '^(?:(\d+):(\d+):(\d+))|(\d+):(\d+)|(\d+)$', 1)) EndFunc Test('10') ; Results (yuck): ; Row 0| ; Row 1| ; Row 2| ; Row 3| ; Row 4| ; Row 5|10 Test('10:20') ; Results (slightly better): ; Row 0| ; Row 1| ; Row 2| ; Row 3|10 ; Row 4|20 Test('10:20:30') ; Results (nice): ; Row 0|10 ; Row 1|20 ; Row 2|30  
    • By Deye
      Hi,
      I want to add any needed conditions to the StringRegExp command so it can pull out only  "File.au3", "WinAPIFiles.au3", "Test.bmp" into the array
      #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include 'WinAPIFiles.au3' #include "File.au3" ; Script Start - Add your code below here Local $bFileInstall = False ; Change to True and ammend the file paths accordingly. ; This will install the file C:\Test.bmp to the script location. If $bFileInstall Then FileInstall("C:\Test.bmp", @ScriptDir & "\Test.bmp") $sFile = FileRead(@ScriptFullPath) $aResults = StringRegExp($sFile, "(?i)(FileInstall\s*|include\s*)(.*)", 3) _ArrayDisplay($aResults) Thanks In Advance
      Deye
×
×
  • Create New...