;################################################# ######################
; Perfect World Database Extractor v.3
; quick typed by Soulpatrol
;
; How to use:
; 0. there must be a folder named IMG inside the tool folder, for the images
; 1. enter URL from your PW Database (pwi, my, ru) in the gui
; 2. set amount of scanned ID´s , eg. 1000 for ID0 up to ID1000 ID
; 3. press START and go shopping or drink a lot coke while scanning.
;
; when finish scanning, look in Tool Folder for: database.db
; u can open this file with any texteditor, images are stored in IMG folder
;
; entrys looks like:
;[ID][@][NAME]
;6@*Steel Falchion
; u can split Item ID and Item Name with @
;
; have fun :D
;################################################# ####################
#include <INet.au3>
#include <String.au3>
#include <array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $counter,$Start_Stop="stop",$ExitLoop=False,$Split count,$SpanStyle,$NameBuff,$ItemColor
Global $item_color[11]
$item_color[0]="#ffffff;"
$item_color[1]="#8080ff;"
$item_color[2]="#ffdc50;"
$item_color[3]="#aa32ff;"
$item_color[4]="#ff6000;"
$item_color[5]="#ffffff;"
$item_color[6]="#b0b0b0;"
$item_color[7]="#00ffae;"
$item_color[8]="#6cfb4b;"
$item_color[9]="#ff0000;"
$item_color[10]="#80ffff;"
$Form1 = GUICreate("PW Database Extractor", 330, 308, 184, 124)
$Group1 = GUICtrlCreateGroup("Amount", 8, 104, 313, 57)
$Label2 = GUICtrlCreateLabel("Scan up to Item ID:", 16, 128, 97, 17)
$MaxITEMS = GUICtrlCreateInput("35000", 114, 124, 81, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$STATUS = GUICtrlCreateLabel("Ready to scan...", 16, 256, 300, 17)
$Group2 = GUICtrlCreateGroup("Status", 8, 240, 313, 57)
$ITEMCount = GUICtrlCreateLabel("0", 96, 276, 220, 17)
$LabelStatus = GUICtrlCreateLabel("Found Items: ", 16, 276, 77, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Language", 8, 32, 313, 65)
$LabelLang = GUICtrlCreateLabel("Enter: pwi, my or ru", 16, 50, 97, 21)
$URL = GUICtrlCreateInput("pwi", 114, 48, 97, 21)
$CHK_DL = GUICtrlCreateCheckbox("Download Item Images too", 16, 72, 157, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("", 8, 168, 313, 65)
Global $Button_Start = GUICtrlCreateButton("Start Scan", 16, 182, 91, 41, $WS_GROUP)
GUICtrlSetOnEvent($Button_Start, "_start")
Global $Button_Stop = GUICtrlCreateButton("Stop Scan", 126, 182, 91, 41, $WS_GROUP)
GUICtrlSetOnEvent($Button_Stop, "_stop")
Global $Button_Exit = GUICtrlCreateButton("Exit", 236, 182, 75, 41, $WS_GROUP)
GUICtrlSetOnEvent($Button_Exit, "_exit")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label4 = GUICtrlCreateLabel('Perfect World Database Extractor by Soulpatrol', 10, 8, 309, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
While 1
$GUIMsg = GUIGetMsg()
switch $GUIMsg
Case $GUI_EVENT_CLOSE
_exit()
Case $Button_Exit
_exit()
Case $Button_Start
if $ExitLoop=False then
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUICtrlSetOnEvent($Button_Exit, "_exit")
GUICtrlSetOnEvent($Button_Stop, "_stop")
_start()
endif
Endswitch
WEnd
Func _stop()
GUICtrlSetState($Button_Start,$GUI_ENABLE)
GUICtrlSetState($Button_Stop,$GUI_DISABLE)
$ExitLoop=True
EndFunc
;################################################# ############
FUNC _start()
if $ExitLoop=False then
GUICtrlSetState($Button_Start,$GUI_DISABLE)
GUICtrlSetState($Button_Stop,$GUI_ENABLE)
;GUICtrlSetData($Button_Start, "Stop Scan")
GetDatabaseIDs(GUICtrlRead($MaxITEMS)) ; amount to search
GUICtrlSetData($STATUS, "Finish scanning and new Database saved...")
GUICtrlSetState($Button_Start,$GUI_ENABLE)
GUICtrlSetState($Button_Stop,$GUI_DISABLE)
Opt("GUIOnEventMode", 0)
endif
EndFunc
;################################################# ############
FUNC _exit()
$ExitLoop=True
Exit
EndFunc
;################################################# ############
FUNC GetDatabaseIDs($items)
$Button_Start = False
;open database as unicode
$hDatabase = FileOpen("database.db",34)
;start the loop
$counter=0
For $x=0 To $items-1
$ItemID = $x
;get website content
$sfileHtml = _INetGetSource("http://www.pwdatabase.com/" & GUICtrlRead($URL) & "/items/" & $ItemID)
;remove tab from html text...
$sfileHtml = StringRegExpReplace($sfileHtml , @CRLF, "@")
; get item name
$ItemName=_StringBetween($sfileHtml,'<th class="itemHeader" colspan="2">','@') ; Item Name
IF not @Error=1 then
$Chinese = StringInStr($ItemName[0], "N/") ; chinese string, not ingame item
IF $Chinese = 0 then ;if not found...
formatName($ItemName[0]) ;format the html stuff and split string...
if not $NameBuff="" Then ; if name not empty
FileWriteLine($hDatabase, $ItemID & "@" & $ItemColor & "@" & $NameBuff & @CRLF); save to database
;if dl image checked
if GUICtrlRead($CHK_DL )=1 then
InetGet("http://www.pwdatabase.com/images/icons/generalm/" & $ItemID & ".gif", "img\" & $ItemID & ".gif", 1)
endif
endif
ENDIF
$counter += 1
ENDIF
;set status counter
GUICtrlSetData($ITEMCount, $counter)
GUICtrlSetData($STATUS, "Scanning Item ID: " & $ItemID & "/" & $items)
If $ExitLoop=True Then ExitLoop
next
FileClose($hDatabase)
EndFunc
;################################################# ####################
FUNC formatName($NameTMP)
;look for spanclass
$SpanStyle = StringInStr($NameTMP, "item_color")
IF $SpanStyle > 0 then
;get item color
$ItemColor=_StringBetween($NameTMP,"'","'>")
;format item color
$ColorNum = StringTrimLeft($ItemColor[0], 10)
$ItemColor=$item_color[$ColorNum]
;remove span
$SpecialChar=_StringBetween($NameTMP,'>','<')
$NameBuff=$SpecialChar[0]
Else
$ItemColor= $item_color[0]
$NameBuff=$NameTMP
endif
$NameBuff = StringRegExpReplace($NameBuff ,"â—�", "•") ; is •
$NameBuff = StringRegExpReplace($NameBuff ,"â—‹", "ο") ; is ο
;look for special html chars...
$pathsplit = StringSplit($NameBuff, ';')
For $Splitcount=1 To $pathsplit[0]-1 ;if found change to unicode...
$SpecialChar=_StringBetween($pathsplit[$Splitcount]&";",'&#',';')
; change special html char to unicode char
$SpecialChar = ChrW($SpecialChar[0])
$NameBuff = StringRegExpReplace($NameBuff, $pathsplit[$Splitcount]&";", $SpecialChar)
next
EndFunc
;################################################# ####################
|