incepator Posted December 12, 2012 Share Posted December 12, 2012 hello! I have a problem! Trying to make a script to search in the source code of a website a list of keywords. I want to search each keyword in the list added. the problem is that I want to display each keyword and how many times that word exists in text. this is my code: expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Array.au3>#Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Cautare in articol ", 704, 357, -1, -1) $Button1 = GUICtrlCreateButton("Add List Keywords", 44, 38, 151, 25, $WS_BORDER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 0) $Input1 = GUICtrlCreateInput("", 240, 40, 457, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $Button2 = GUICtrlCreateButton("Search", 8, 74, 51, 25, $WS_BORDER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 0) $Graphic1 = GUICtrlCreateGraphic(8, 68, 688, 2) GUICtrlSetBkColor(-1, 0x000000) $ListView1 = GUICtrlCreateListView("Nr.|Links|Keywords|Repeat Keywords", 9, 104, 687, 249) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 60) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 350) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 120) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150) $Progress1 = GUICtrlCreateProgress(64, 80, 630, 17) GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $var2 = FileOpenDialog("Add", @ScriptDir & "\", "txt (*.txt)", 1 + 4, "", $Form1) If Not @error Then GUICtrlSetData($Input1, $var2) EndIf Case $Button2 _func_search_active() EndSwitch WEnd Func _func_search_active() $Link0 = "http://pervegalit.wordpress.com/2008/05/31/drugs-to-make-you-smart/#comment-1388" $Link = _IECreate($Link0, Default, 0, 1, 0) $Read_html = _IEBodyReadHTML($Link) $Text_Limita = StringSplit($Read_html,"<DIV class=comment-content>",1) $Linii = _StringBetween($Text_Limita[1], '<P>','</P>') _IEQuit($Link) If IsArray($Linii) Then $Linii_Unice = _ArrayUnique($Linii) $Open_Read = FileOpen(GUICtrlRead($Input1), 0) For $i = 1 To UBound($Linii_Unice)-1 ;$Linii_Unice[$i] = text $Read = FileReadLine($Open_Read) StringReplace($Linii_Unice[$i], $Read, "") $Create = GUICtrlCreateListViewItem($i&"|"&$Link0&"|"&$Read&"|"&@extended, $ListView1) Next MsgBox(0,"","Finish !") EndIf EndFunckeywords.txt Link to comment Share on other sites More sharing options...
incepator Posted December 12, 2012 Author Share Posted December 12, 2012 (edited) UPDATEI solved part of the script, I have one problem that I can not find solution.How can I exclude this "repeat keywords" = 0 ?expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> #include <File.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("", 704, 357, -1, -1) $Button1 = GUICtrlCreateButton("Add List Keywords", 44, 38, 151, 25, $WS_BORDER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 0) $Input1 = GUICtrlCreateInput("", 240, 40, 457, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $Button2 = GUICtrlCreateButton("Search", 8, 74, 51, 25, $WS_BORDER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 0) $Graphic1 = GUICtrlCreateGraphic(8, 68, 688, 2) GUICtrlSetBkColor(-1, 0x000000) $ListView1 = GUICtrlCreateListView("Nr.|Links|Keywords|Repeat Keywords", 9, 104, 687, 249) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 60) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 350) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 120) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150) $Progress1 = GUICtrlCreateProgress(64, 80, 630, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $var2 = FileOpenDialog("Add", @ScriptDir & "", "txt (*.txt)", 1 + 4, "", $Form1) If Not @error Then GUICtrlSetData($Input1, $var2) EndIf Case $Button2 _func_search_active() EndSwitch WEnd Func _func_search_active() $Link0 = "http://pervegalit.wordpress.com/2008/05/31/drugs-to-make-you-smart/#comment-1388" $Link = _IECreate($Link0, Default, 0, 1, 0) $Read_html = _IEBodyReadHTML($Link) ClipPut($Read_html) $Text_Limita = StringSplit($Read_html,"content>",1) $Linii = _StringBetween($Text_Limita[1], '<P>','</P>') _IEQuit($Link) If IsArray($Linii) Then $Linii_Unice = _ArrayUnique($Linii) For $i = 1 To UBound($Linii_Unice) Global $aArrayCombo = _ArrayCombinations($Linii_Unice, $i, @CRLF) Next $TextFinal = $aArrayCombo[1] $count = _FileCountLines(GUICtrlRead($Input1)) $Open_Read = FileOpen(GUICtrlRead($Input1), 0) For $ii = 1 To $count $Read = FileReadLine($Open_Read) StringReplace($TextFinal, $Read, "") $Create = GUICtrlCreateListViewItem($ii&"|"&$Link0&"|"&$Read&"|"&@extended, $ListView1) Next MsgBox(0,"","Finish !") EndIf EndFunc Edited December 12, 2012 by incepator Link to comment Share on other sites More sharing options...
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