Clever1mba Posted July 6, 2005 Posted July 6, 2005 Hello here is code for search websites in txt file but have lot possibilty to improveproblem in this code it search http:// but if text file contain website link like this http://domain1.com http://domain2.comit should be spreated to other line like this http://domain1.comhttp://domain2.comif some one have littile time and trick plz improve that code for all cheerzzzzzzzz#include <Array.au3>#include <GUIConstants.au3>GUICreate("TEST SEARCH") $myedit=GUICtrlCreateEdit (""& @CRLF, 1,50,400,300,$ES_AUTOVSCROLL+$WS_VSCROLL)GUISetState ()Dim $DLine$Text = "test.txt";^^^^^ YOU NEED TO SET THIS LOCATION ABOVE ^^^^$NFile = FileOpen($Text, 0); Check if file opened for reading OKIf $NFile = -1 Then MsgBox(0, "Error", "Unable to open file.")EndIfDim $Data_[101], $newID=""; to set-up for an array - if you want an array; Read in lines of text until the EOF is reachedWhile 1 $NLine = FileReadLine($NFile) If @error = -1 Then ExitLoop If $NLine <> "" Then ; for a string $string = "http://" if StringInStr( $NLine, $string,0 ,-1) Then $DLine = $NLine GUICtrlSetData( $myedit, $DLine & @CRLF,1) EndIf EndIfWEndFileClose($NFile)While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoopWend
w0uter Posted July 6, 2005 Posted July 6, 2005 stringreplace ' ' with @CRLF ? My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
Clever1mba Posted July 6, 2005 Author Posted July 6, 2005 (edited) hello thanks but still results r not good i get some extra text with resultxxxxxxhttp://domain.comxxxxxxxhow to trim that extra text to get clean resutls #include <Array.au3>#include <GUIConstants.au3>GUICreate("TEST SEARCH") $myedit=GUICtrlCreateEdit (""& @CRLF, 1,50,400,300,$ES_AUTOVSCROLL+$WS_VSCROLL)GUISetState ()Dim $DLine$Text = "index.htm";^^^^^ YOU NEED TO SET THIS LOCATION ABOVE ^^^^$NFile = FileOpen($Text, 0); Check if file opened for reading OKIf $NFile = -1 Then MsgBox(0, "Error", "Unable to open file.")EndIfDim $Data_[101], $newID=""; to set-up for an array - if you want an array; Read in lines of text until the EOF is reachedWhile 1 $NLine = FileReadLine($NFile) If @error = -1 Then ExitLoop If $NLine <> "" Then ; for a string if StringInStr( $NLine, "http://",0 ,-1) Then $DLine = StringReplace($NLine, " ", @CRLF) GUICtrlSetData( $myedit, $DLine & @CRLF,1) EndIf EndIfWEndFileClose($NFile)While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoopWend Edited July 6, 2005 by asimzameer
Valuater Posted July 6, 2005 Posted July 6, 2005 look in help for string trim right and string trim left ( you still have not removed some of my comments in your script) 8)
Clever1mba Posted July 7, 2005 Author Posted July 7, 2005 hello i try to put some filter and it give result much better now but lots of extrat text with result i just want result like this www.domain1.com www.domain2.com www.domain3.com www.domain4.com www.domain5.com www.domain6.com www.domain7.com www.domain8.com www.domain9.com www.domain10.com any one like to help build this proper #include <Array.au3> #include <GUIConstants.au3> GUICreate("TEST SEARCH") $myedit=GUICtrlCreateEdit (""& @CRLF, 1,50,400,300,$ES_AUTOVSCROLL+$WS_VSCROLL) GUISetState () Dim $DLine $Text = "myfile.htm" $NFile = FileOpen($Text, 0) If $NFile = -1 Then MsgBox(0, "Error", "Unable to open file.") EndIf Dim $Data_[101], $newID="" While 1 $NLine = FileReadLine($NFile) If @error = -1 Then ExitLoop If $NLine <> "" Then if StringInStr( $NLine , 'www' ) Then $DLine1 = StringReplace($NLine, " ", @CRLF) $DLine2 = StringReplace($DLine1, ">", @CRLF) $DLine3 = StringReplace($DLine2, "<", @CRLF) $DLine4 = StringReplace($DLine3, "http", @CRLF) $DLine5 = StringReplace($DLine4, "," , @CRLF) $DLine6 = StringReplace($DLine5, "/" , @CRLF) $DLine7 = StringReplace($DLine6, "\" , @CRLF) $DLine8 = StringReplace($DLine7, ";" , @CRLF) $DLine9 = StringReplace($DLine8, ":" , @CRLF) $DLine10 = StringReplace($DLine9, "[" , @CRLF) $DLine11 = StringReplace($DLine10, "]" , @CRLF) $DLine12 = StringReplace($DLine11, "}" , @CRLF) $DLine13 = StringReplace($DLine12, "{" , @CRLF) $DLine14 = StringReplace($DLine13, "%" , @CRLF) $DLine15 = StringReplace($DLine14, "+" , @CRLF) $DLine16 = StringReplace($DLine15, "=" , @CRLF) $DLine17 = StringReplace($DLine16, ")" , @CRLF) $DLine18 = StringReplace($DLine17, "(" , @CRLF) $DLine19 = StringReplace($DLine18, "-" , @CRLF) $DLine20 = StringReplace($DLine19, "'" , @CRLF) $DLine21 = StringReplace($DLine20, '"' , @CRLF) GUICtrlSetData( $myedit, $DLine21 & @CRLF,1) EndIf EndIf WEnd FileClose($NFile) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend
JSThePatriot Posted July 7, 2005 Posted July 7, 2005 I havent the time to really get into this project with you, but just looking over the above code I notice you are replacing alot of special characters with @CRLF which creates a newline, so you are going to have alot of white space. If you are wanting a clean list you may need to use the RegExp() in the beta version, and or learn the StringTrim() functions. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Valuater Posted July 7, 2005 Posted July 7, 2005 (edited) First When you want to show your script use this [ code ] ************** copy paste your code here [ / code] without spaces, looks like this ********* copy/paste your code here then we can see if it is correct 8) Edited July 7, 2005 by Valuater
Clever1mba Posted July 7, 2005 Author Posted July 7, 2005 (edited) hello Valuaterokay chk now and tell how to use StringRegExp in code StringRegExp ( "test", "pattern", [ flag ])expandcollapse popup#include <Array.au3> #include <GUIConstants.au3> GUICreate("TEST SEARCH") $myedit=GUICtrlCreateEdit (""& @CRLF, 1,50,400,300,$ES_AUTOVSCROLL+$WS_VSCROLL) GUISetState () Dim $DLine $Text = "myfile.htm" $NFile = FileOpen($Text, 0) If $NFile = -1 Then MsgBox(0, "Error", "Unable to open file.") EndIf Dim $Data_[101], $newID="" While 1 $NLine = FileReadLine($NFile) If @error = -1 Then ExitLoop If $NLine <> "" Then if StringInStr( $NLine , 'www' ) Then $DLine1 = StringReplace($NLine, " ", @CRLF) $DLine2 = StringReplace($DLine1, ">", @CRLF) $DLine3 = StringReplace($DLine2, "<", @CRLF) $DLine4 = StringReplace($DLine3, "http", @CRLF) $DLine5 = StringReplace($DLine4, "," , @CRLF) $DLine6 = StringReplace($DLine5, "/" , @CRLF) $DLine7 = StringReplace($DLine6, "\" , @CRLF) $DLine8 = StringReplace($DLine7, ";" , @CRLF) $DLine9 = StringReplace($DLine8, ":" , @CRLF) $DLine10 = StringReplace($DLine9, "[" , @CRLF) $DLine11 = StringReplace($DLine10, "]" , @CRLF) $DLine12 = StringReplace($DLine11, "}" , @CRLF) $DLine13 = StringReplace($DLine12, "{" , @CRLF) $DLine14 = StringReplace($DLine13, "%" , @CRLF) $DLine15 = StringReplace($DLine14, "+" , @CRLF) $DLine16 = StringReplace($DLine15, "=" , @CRLF) $DLine17 = StringReplace($DLine16, ")" , @CRLF) $DLine18 = StringReplace($DLine17, "(" , @CRLF) $DLine19 = StringReplace($DLine18, "-" , @CRLF) $DLine20 = StringReplace($DLine19, "'" , @CRLF) $DLine21 = StringReplace($DLine20, '"' , @CRLF) GUICtrlSetData( $myedit, $DLine21 & @CRLF,1) EndIf EndIf WEnd FileClose($NFile) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Edited July 7, 2005 by asimzameer
Valuater Posted July 7, 2005 Posted July 7, 2005 I understand this is your results you want to clean-upxxxxxxhttp://domain.comxxxxxxx$test = "xxxxxxhttp://domain.comxxxxxxx"$result = StringTrimLeft( $test, 6)will give this $result = "http://domain.comxxxxxxx"then$result_2 = StringTrimRight( $result, 7)final line$result_2 = "http://domain.com"and thats the approach8)
Clever1mba Posted July 7, 2005 Author Posted July 7, 2005 (edited) opps man its not necessary it just example xxxxxxhttp://domainxxxxx myfile.html contain links but we donno how much text contain at left and right i have simple question that how can result be neat if html contain url link we donno myfile.htm contain how many links we just want to extract with clean results just simply do path one html file contain few webiste links and chk ur self with code and notice result are not clean and clear i hope u get my point Edited July 7, 2005 by asimzameer
blindwig Posted July 7, 2005 Posted July 7, 2005 If it's an html file you're searching through, then just get all the anchor text. Like this: <a href="http://www.autoitscript.com">AutoIt</a> so, search for '<a href=' and then read until an endquote (or double quote) or a greater-than symbol. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
Valuater Posted July 7, 2005 Posted July 7, 2005 i got it with string trim also $test = "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxhttp://my-domain.comxxxxxssssssssssssssssssssssxx" $L_loc = StringInStr($test, "http") $result = StringTrimLeft( $test, $L_loc -1) $R_loc = StringInStr($result, ".com", 0, -1) $result_2 = StringLeft( $result, $R_loc +3) MsgBox(0,"test", "final result = " & $result_2) good luck 8)
Clever1mba Posted July 7, 2005 Author Posted July 7, 2005 (edited) okay valuater i add this code and results much better now but lots of duplicate copies one more thing i want to search now multiple file like *.htm *.php *.asp im mean if folder contain lots off html asp and php file can we search all of them and get results if yes plz tell me wat exact code would be THANKS Edited July 7, 2005 by asimzameer
Valuater Posted July 7, 2005 Posted July 7, 2005 (edited) results much better now but lots of duplicate copies#include <GUIConstants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> Dim $result_3 = "" $test = "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxhttp://my-domain.comxxxxxssssssssssssssssssssssxx" $L_loc = StringInStr($test, "http") $result = StringTrimLeft( $test, $L_loc -1) $R_loc = StringInStr($result, ".com", 0, -1) $result_2 = StringLeft( $result, $R_loc +3) If $result_2 <> $result_3 Then $result_3 = $result_2 ;write the line to the file MsgBox(0,"test", "final result = " & $result_3) EndIfthis will stop duplicates8) Edited July 7, 2005 by Valuater
Valuater Posted July 8, 2005 Posted July 8, 2005 (edited) one more thing i want to search now multiple file like *.htm *.php *.asp im mean if folder contain lots off html asp and php file can we search all of them and get resultsYou want to do a loop inside of a loop... you should follow this post toohttp://www.autoitscript.com/forum/index.php?showtopic=13255#good luck8) Edited July 8, 2005 by Valuater
Clever1mba Posted July 8, 2005 Author Posted July 8, 2005 i did'nt get somthing at url have any example of multiple file search then plz share it
Valuater Posted July 8, 2005 Posted July 8, 2005 one more thing i want to search now multiple file like *.htm *.php *.asp im mean if folder contain lots off html asp and php file can we search all of them and get resultsStep 1You need to place your current search below this or in a function.... i will use a function call for this example.... its hard to explain everythingFunc HTML_Search()******all of your previous search patern goes in here*** so we can *call* it after searching for the above requested files*******EndFuncStep 2Use this *you need to alter for your computer* to search for the above files$Loc = @HomeDrive & "\*.html" RunWait(@ComSpec & ' /c ' & 'dir "' & $Loc & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE) Sleep(2000) $LFile = FileOpen(@TempDir & "\dir.txt", 0) ; Check if file opened for reading OK If $LFile = -1 Then MsgBox(0, "Error", "Unable to open file.") Return EndIf ; Read in lines of text until the EOF is reached While 1 $LLine = FileReadLine($LFile) If @error = -1 Then ExitLoop If $LLine <> "" Then Call("HTML_Search"); this sends the info to the original file search $Msg2 = GUIGetMsg() If $Msg2 = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd FileClose($hFile)hope you understand the ideayou have to search for the files you want (with this new search).... thensearch inside those files with your other/original searchgood luck8)
Clever1mba Posted July 8, 2005 Author Posted July 8, 2005 i trying this but its just scrolling with no result expandcollapse popup#include <Array.au3> #include <GUIConstants.au3> GUICreate("TEST SEARCH") $myedit=GUICtrlCreateEdit (""& @CRLF, 1,50,400,300,$ES_AUTOVSCROLL+$WS_VSCROLL) GUISetState () Dim $DLine $Loc = @HomeDrive & "\*.html" RunWait(@ComSpec & ' /c ' & 'dir "' & $Loc & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE) Sleep(2000) $NFile = FileOpen(@TempDir & "\dir.txt", 0) If $NFile = -1 Then MsgBox(0, "Error", "Unable to open file.") EndIf Dim $Data_[101], $newID="" While 1 $NLine = FileReadLine($NFile) If @error = -1 Then ExitLoop If $NLine <> "" Then EndIf WEnd FileClose($NFile) While 1 Call("HTML_Search") $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func HTML_Search() $L_loc = StringInStr($NLine, "http") $result = StringTrimLeft( $NLine, $L_loc -1) $R_loc = StringInStr($result, ".com", 0, -1) $result_2 = StringLeft( $result, $R_loc +3) GUICtrlSetData( $myedit, $result_2 & @CRLF,1) EndFunc
Valuater Posted July 8, 2005 Posted July 8, 2005 you have completely "mixed" the two searches they are "two" seperate searches The one i just gave you will find the *.html files the one you already had with read the *.html files ok 8)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now