| »Master |
| | Allora, siccome mi rompevo di aggiornare la lista programmi manualmente, ho fatto questo script che legge le sezioni interessate e crea direttamente il codice HTML da incollare sulla Lista Programmi L'algoritmo originale è fatto completamente da me, se lo usate su qualche altro vostro script, provate a darmi qualche credito, in quanto non ho mai visto algoritmi del genere xD Anzi, se riuscite a capire qualcosa, perché l'ho scriptato perché io capissi, quindi le variabili hanno nomi stronzi, le funzioni non sono indipendenti e ci sono tanti artifici che non riuscirò nemmeno a spiegarvi xD Comunque, lo script di per se è abbastanza modificabile, sono 301 linee, quindi lo posto direttamente qui Se volete spiegazioni sul suo funzionamento, non esitate a chiedermelo PS: Siccome ha pochissima interfaccia grafica, se volete capire cosa sta facendo, guardate sulla console, quindi consiglio avere la Scite4AutoIt3 più aggiornata CODICE #include<Array.au3> $MAINDomain="autoit" Global $MAINSezione[2]=["2401813", "2779935"] ;~ Global $MAINSezione[3]=["2401813", "6147482", "2779935"]
Global $topics[1][6], $users[1][5], $EXCLUDEutente="6945205:", $EXCLUDEtopic="38605754:41032125:", $listaUtentiIgnorati="", $TopicIgnorati=0 Global $EXCLUDEtitolo="" ; sintasse - parola:altraparola:asdasd: (lo stesso per $EXCLUDEutente e $EXCLUDEtopic) ; $EXCLUDEtitolo è la blacklist per il titolo. Se è presente la parola isolata, non aggiunge il topic e visualizza l'info sul debug ; per esempio, $EXCLUDEtitolo="bot:hack:" esclude titoli come "Un'altro bot per darkorbit" "Ultrasuperhaxor hack per metin2" ; però non esclude MultiBot per metin2, per esempio. il che è modificabile, guardare la funzione _GetPoints, precisamente sulla parte ; in commento. Global $gTitle='Analizza Lista Programmi by »Master (build 07/09/2012)' Global $nTOP=20 Global $mainCache=@TempDir Global $AGGIORNA_INDEX=False Global $HTMLcode="Questo generatore di database per la Lista Programmi è stato creato da »Master.<br>"& _ "Database generato il "&@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN
If FileExists($mainCache&"\"&$MAINDomain&"s"&$MAINSezione[0]&".dat") Then $ftime=FileGetTime($mainCache&"\"&$MAINDomain&"s"&$MAINSezione[0]&".dat") If MsgBox(48+4, $gTitle, "Ci sono alcuni file in cache, se li cancelli, scaricherò i file più aggiornati dal forum, il che potrà rendere il processo più lento."&@CRLF& _ "L'indice è del "&$ftime[2]&"/"&$ftime[1]&"/"&$ftime[0]&" "&$ftime[3]&":"&$ftime[4]&" ."&@CRLF& _ "Premi SI per cancellare la cache (più lento) oppure NO per mantenerla (più veloce però l'indice non è il più aggiornato)")=6 Then $AGGIORNA_INDEX=True Else $AGGIORNA_INDEX=False Global $HTMLcode="Questo generatore di database per la Lista Programmi è stato creato da »Master.<br>"& _ "Database generato il "&$ftime[2]&"/"&$ftime[1]&"/"&$ftime[0]&" "&$ftime[3]&":"&$ftime[4] EndIf EndIf
; Inizio algoritmo vero e proprio asd For $nSEZ=0 To UBound($MAINSezione, 1)-1 __DebugWrite("Lettura sezione "&$MAINSezione[$nSEZ]&" in corso... $nSEZ="&$nSEZ) $SEZread=_InetGet_FAST("http://"&$MAINDomain&".forumcommunity.net/?f="&$MAINSezione[$nSEZ], $mainCache&"\"&$MAINDomain&"s"&$MAINSezione[$nSEZ]&".dat") _WaitInetProgress($SEZread) $SEZnPAGES=_GetPageNum($mainCache&"\"&$MAINDomain&"s"&$MAINSezione[$nSEZ]&".dat") __DebugWrite("Numero di pagine: "&$SEZnPAGES) If $SEZnPAGES=0 Then __DebugWrite(" Attenzione! Numero di pagine è uguale a 0 (SEZnPAGES=0)"&@CRLF&"Provo ad annalizzare lo stesso...") For $nPAG=0 To $SEZnPAGES-1 __DebugWrite("Lettura sezione: pagina "&($nPAG+1)&"/"&$SEZnPAGES&"... (nPAG="&$nPAG&") (IDsez="&$MAINSezione[$nSEZ]&")") $PAGread=_InetGet_FAST("http://"&$MAINDomain&".forumcommunity.net/?f="&$MAINSezione[$nSEZ]&"&st="&($nPAG*30), $mainCache&"\"&$MAINDomain&"s"&$MAINSezione[$nSEZ]&"p"&$nPAG&".dat") _WaitInetProgress($PAGread) $tag="" Switch $nSEZ Case 0 $tag="" ;~ Case 1 ;~ $tag="Anti-Lamer" Case 1 $tag="UDF" EndSwitch _GetTopics($mainCache&"\"&$MAINDomain&"s"&$MAINSezione[$nSEZ]&"p"&$nPAG&".dat", $tag) If Not IsArray($topics) Then __DebugWrite("--------------------------"&@CRLF&" - ERRORE CRITICO nella sezione (nPAG="&$nPAG&") (IDsez="&$MAINSezione[$nSEZ]&") !"&@CRLF& _ "Probabilmente è una sezione restrita. Ignorando..."&@CRLF& _ "--------------------------") Sleep(5000) ContinueLoop EndIf Next Next
_ArrayDisplay($topics)
If UBound($topics, 1)>1 Then ReDim $topics[UBound($topics, 1)-1][UBound($topics, 2)]
__DebugWrite("Inizio parsing...") Sleep(500) __DebugWrite("Trovate "&UBound($topics, 1)&" discussioni valide.")
__DebugWrite("Fusione utenti in corso...") For $x=0 To UBound($topics, 1)-1 If IsInt($x/33) Then __DebugWrite("Fusione utenti in corso... "&Round(($x/(UBound($topics)-1))*100)&"%") For $u=0 To UBound($users, 1)-1 If $users[$u][1]=$topics[$x][2] Then ExitLoop Next If $u=UBound($users, 1) Then ReDim $users[$u+1][UBound($users, 2)] $users[$u][0]=$topics[$x][3] $users[$u][1]=$topics[$x][2] $users[$u][2]="" $users[$u][3]=0 $users[$u][4]=0 EndIf If Not StringInStr($users[$u][0], $topics[$x][3]) Then $users[$u][0]&=" ; "&$topics[$x][3] $users[$u][2]&=$x&":" $users[$u][3]+=$topics[$x][4] $users[$u][4]+=$topics[$x][5] Next
__DebugWrite("Formattando utenti...") For $u=0 To UBound($users, 1)-1 $users[$u][2]=StringTrimRight($users[$u][2], 1) Next
__DebugWrite("Parsing utenti in ordine alfabetico...") _ArraySort($users)
__DebugWrite("Generando TOP"&$nTOP&" Programmi in basi alle visite...") $TOPprogrammi="" For $n=1 To $nTOP __DebugWrite("Generando TOP"&$nTOP&" Programmi in basi alle visite... "&Round(($n/$nTOP)*100)&"%") $i=-1 For $x=0 To UBound($topics, 1)-1 If StringInStr($TOPprogrammi, ":"&$x&";") Or StringInStr($topics[$x][1], "(UDF)") Then ContinueLoop ;Or StringInStr($topics[$x][1], "(Anti-Lamer)") Then ContinueLoop If $i=-1 Or Number($topics[$x][5])>Number($topics[$i][5]) Then $i=$x Next $TOPprogrammi&=":"&$i&";" Next $TOPprogrammi=StringTrimLeft($TOPprogrammi, 1)
__DebugWrite("Generando HTMLcode per TOP"&$nTOP&" Programmi...") $TOPprogrammi=StringSplit($TOPprogrammi, ":") $HTMLcode&="<br><br>Top"&$nTOP&" Programmi<br>" For $x=1 To $TOPprogrammi[0] $TOPprogrammi[$x]=StringReplace($TOPprogrammi[$x], ";", "") $HTMLcode&=ChrW(9679)&" "&' <a href="?t='&$topics[$TOPprogrammi[$x]][0]&'" target="_blank">'&$topics[$TOPprogrammi[$x]][1]&'</a> - '& _ "V: "&$topics[$TOPprogrammi[$x]][5]&" - C: "&$topics[$TOPprogrammi[$x]][4]&" - "& _ 'by <a href="?act=Profile&MID='&$topics[$TOPprogrammi[$x]][2]&'" target="_blank">'&$topics[$TOPprogrammi[$x]][3]&'</a><br>' Next
;~ __DebugWrite("Generando struttura su debug...") ;~ For $u=0 To UBound($users, 1)-1 ;~ If $users[$u][0]="" Then ContinueLoop ;~ $DB=StringSplit($users[$u][2], ":") ;~ __DebugWrite($users[$u][0]&" (ID:"&$users[$u][1]&") - Programmi: "&$DB[0]&" Commenti: "&$users[$u][3]&" Visite: "&$users[$u][4]) ;~ For $i=1 To $DB[0] ;~ __DebugWrite(@TAB&$topics[$DB[$i]][1]&" (ID:"&$topics[$DB[$i]][0]&") - Commenti: "&$topics[$DB[$i]][4]&" Visite: "&$topics[$DB[$i]][5]) ;~ Next ;~ Next
__DebugWrite("Generando codice HTML del database...") If $TopicIgnorati>=1 Then $HTMLcode&="<br><br>BLACKLIST Automatica:<br>" $HTMLcode&="Ci sono utenti esclusi [SPOILER] "&$listaUtentiIgnorati&" [/SPOILER]<br>" $HTMLcode&=$TopicIgnorati&" topic ignorati dalla blacklist, che non saranno linkati qui." EndIf $HTMLcode&="<br><br>DATABASE<br><br>" For $u=0 To UBound($users, 1)-1 If $users[$u][0]="" Then ContinueLoop If IsInt($u/33) Then __DebugWrite("Generando codice HTML del database... "&Round(($u/(UBound($users, 1)-1))*100)&"%") $DB=StringSplit($users[$u][2], ":") $HTMLcode&=ChrW(9679)&' <a href="?act=Profile&MID='&$users[$u][1]&'" target="_blank">'&$users[$u][0]&'</a>'& _ " - Programmi: <b>"&$DB[0]&"</b> - Commenti: <b>"&$users[$u][3]&"</b> - Visite: <b>"&$users[$u][4]&"</b> <br>" For $i=1 To $DB[0] $HTMLcode&=ChrW(187)&ChrW(187)&' <a href="?t='&$topics[$DB[$i]][0]&'" target="_blank">'&$topics[$DB[$i]][1]&'</a>'& _ " - C: "&$topics[$DB[$i]][4]&" - V: "&$topics[$DB[$i]][5]&" <br>" Next $HTMLcode&="<br><br>" Next __DebugWrite("Formattando caratteri speciali...") $HTMLcode=_HTMLSpecialCharConvert($HTMLcode)
__DebugWrite("Creando output...")
$nGUI=GUICreate($gTitle, 300, 330) GUICtrlCreateEdit($HTMLcode, 10, 10, 280, 280, BitOR(0x00200000, 0x0800)) $copyButton=GUICtrlCreateButton("Copy to Clip [ctrl-C]", 10, 300, 140, 20) $closeButton=GUICtrlCreateButton("Close this window", 150, 300, 140, 20) GUISetState() __DebugWrite("Finito.") Do Sleep(50) Switch GUIGetMsg() Case -3, $closeButton Exit Case $copyButton ClipPut($HTMLcode) MsgBox(64, $gTitle, "HTML Code inserito nel clipboard (CTRL-C)") EndSwitch Until False
Func _HTMLSpecialCharConvert($text) Local $RegEx=StringRegExp($text, '&#(.*?);', 3) If IsArray($RegEx) Then For $i=0 To UBound($RegEx, 1)-1 $text=StringReplace($text, '&#'&$RegEx[$i]&';', Chr($RegEx[$i])) Next EndIf Return $text EndFunc
Func _WaitInetProgress($inetHANDLE, $nDISC=-1) $WIPtimer=TimerInit() Do Sleep(5) $info=InetGetInfo($inetHANDLE, -1) If TimerDiff($WIPtimer)>=15000 And $nDISC>=0 Then __DebugWrite(" ATTENZIONE - Il download del topic è stato interrotto. Reloading... (nDISC="&$nDISC&")") InetClose($inetHANDLE) FileDelete($mainCache&"\"&$MAINDomain&"t"&$topics[$nDISC]&".dat") $inetHANDLE=InetGet("http://"&$MAINDomain&".forumcommunity.net/?t="&$topics[$nDISC], $mainCache&"\"&$MAINDomain&"t"&$topics[$nDISC]&".dat", 0, 1) $WIPtimer=TimerInit() EndIf Until $inetHANDLE=-10 Or $info[2] EndFunc
Func _InetGet_FAST($URL, $FILE) If $AGGIORNA_INDEX=True Then FileDelete($FILE) If FileExists($FILE) Then Return -10 Return InetGet($URL, $FILE, 1, 1) EndFunc
Func _HTML_GetTitle($file) Local $Reg $Reg=StringRegExp(FileRead($file), "<title>(.*?)<\/title>", 3) If IsArray($Reg) Then Return $Reg[0] EndFunc
Func _GetPageNum($file) $Reg1=StringRegExp(FileRead($file), '<ul class="pages"><li>(.*?) <li>', 3) If Not IsArray($Reg1) Then $Reg2=1 Else $Reg2=StringRegExp($Reg1[0], ' \((.*?)\)', 3) $Reg2=$Reg2[0] EndIf Return $Reg2 EndFunc
Func _GetTopics($file, $tag="") $Reg1=StringRegExp(FileRead($file), '<div class="main5">(.*)<\/table><\/div><\/div>', 3) If Not (IsArray($Reg1)) Then FileDelete($file) Return -1 EndIf $Reg2=StringRegExp($Reg1[0], '<td class="bb">(.*?)<td', 3) ; ID+NOME - TOPIC $Reg4=StringRegExp($Reg1[0], '<td class="aa">(.*?)">', 3) ; MOVED? $Reg5=StringRegExp($Reg1[0], '<td class="ww">(.*?)<td', 3) ; IMPORTANTE? $Reg6=StringRegExp($Reg1[0], '<td class="cc">(.*?)<td', 3) ; RISPOSTE $Reg7=StringRegExp($Reg1[0], '<td class="yy">(.*?)<td', 3) ; VISITE $Reg8=StringRegExp($Reg1[0], '<td class="xx">(.*?)<td', 3) ; INFO - AUTORE ;__DebugWrite("UBound($Reg2)="&UBound($Reg2)&" UBound($Reg4)="&UBound($Reg4)&" UBound($Reg5)="&UBound($Reg5)&" UBound($Reg6)="&UBound($Reg6)&" UBound($Reg7)="&UBound($Reg7)&" UBound($Reg8)="&UBound($Reg8)) If Not (IsArray($Reg1) And IsArray($Reg2) And IsArray($Reg4) And IsArray($Reg8)) Then __DebugWrite("Errore RegExp") __DebugWrite("UBound($Reg2)="&UBound($Reg2)&" UBound($Reg4)="&UBound($Reg4)&" UBound($Reg5)="&UBound($Reg5)&" UBound($Reg6)="&UBound($Reg6)&" UBound($Reg7)="&UBound($Reg7)&" UBound($Reg8)="&UBound($Reg8)) FileDelete($file) Return -1 EndIf For $x=0 To UBound($Reg2, 1)-1 If (IsArray($Reg4) And StringInStr($Reg4[$x], "B_MOVED", 3)) Or (IsArray($Reg5) And StringInStr($Reg5[$x], ChrW(183), 3)) Then ContinueLoop $Reg3=StringRegExp($Reg2[$x], '<a href="http:\/\/'&$MAINDomain&'.forumcommunity.net\/\?t=(.*?)"', 3) ; ID TOPIC $Reg11=StringRegExp(StringTrimLeft($Reg2[$x], StringInStr($Reg2[$x], "title=")), '">(.*?)<\/a><\/h2>', 3) ; NOME TOPIC $Reg9=StringRegExp($Reg8[$x], '<a href="http:\/\/'&$MAINDomain&'.forumcommunity.net\/\?act=Profile&MID=(.*?)"', 3) ; ID AUTORE $Reg10=StringRegExp($Reg8[$x], '">(.*?)<\/a>', 3) ; NICK AUTORE If Not (IsArray($Reg3) And IsArray($Reg11) And IsArray($Reg9) And IsArray($Reg10)) Then ContinueLoop If StringInStr($EXCLUDEutente, $Reg9[0]&":") Then __DebugWrite("Attenzione: Escluso utente "&$Reg10[0]) $str=StringInStr($listaUtentiIgnorati, $Reg10[0]) $TopicIgnorati+=1 If @error Or $str<1 Then $listaUtentiIgnorati&=" "&$Reg10[0] ContinueLoop EndIf If StringInStr($EXCLUDEtopic, $Reg3[0]&":") Then __DebugWrite("Attenzione: Escluso topico "&$Reg11[0]) $TopicIgnorati+=1 ContinueLoop EndIf
; - Algoritmo 1 - Blacklist per topic che contengono la parola-chiave isolata nel titolo $splitTitolo=StringSplit($Reg11[0], " ") For $bl=1 To $splitTitolo[0] If StringInStr($EXCLUDEtitolo, $splitTitolo[$bl]&":") Then ExitLoop Next
; - Algoritmo 2 - Blacklist per topic che contengono la parola-chiave in qualsiasi modo nel titolo ;~ $splitTitolo=StringSplit($EXCLUDEtitolo, ":") ;~ For $bl=1 To $splitTitolo[0]-1 ;~ If StringInStr($Reg11[0], $splitTitolo[$bl]) Then ExitLoop ;~ Next
If $bl<=$splitTitolo[0] Then __DebugWrite("Attenzione: Escluso topico "&$Reg11[0]&@TAB&" ( BLACKLIST - "&$splitTitolo[$bl]&" )") $TopicIgnorati+=1 ContinueLoop EndIf
If Not IsArray($Reg6) Then Local $Reg6[1]=[0] If Not IsArray($Reg7) Then Local $Reg7[1]=[0] $topics[UBound($topics, 1)-1][0]=$Reg3[0] ; ID TOPIC $topics[UBound($topics, 1)-1][1]=$Reg11[0] ; NOME TOPIC If StringLen($tag)>=1 Then $topics[UBound($topics, 1)-1][1]="("&$tag&") "&$Reg11[0] ; NOME TOPIC $topics[UBound($topics, 1)-1][2]=$Reg9[0] ; ID AUTORE $topics[UBound($topics, 1)-1][3]=$Reg10[0] ; NOME AUTORE $topics[UBound($topics, 1)-1][4]=$Reg6[$x] ; RISPOSTE $topics[UBound($topics, 1)-1][5]=$Reg7[$x] ; VISITE ReDim $topics[UBound($topics, 1)+1][UBound($topics, 2)] Next EndFunc
Func __DebugWrite($txt, $line=@ScriptLineNumber) Local $split, $x, $ftxt $split=StringSplit($txt, @CRLF) For $x=1 To $split[0] If Not $split[$x]="" Then $ftxt=@CRLF&@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&" @line "&$line&@TAB&" | "&$split[$x] ConsoleWrite($ftxt) EndIf Next EndFunc
| | |
| |
|