Dampe Posted February 13, 2009 Share Posted February 13, 2009 (edited) I'm trying to parse raw html into a big string, just leaving the important things behind. Func _SearchForQuest() Local $GlobalQuestURL = "http:http://thottbot.com/?s=" $tSearchParam = GUICtrlRead ($GUIInpts[5]) If $tSearchParam <> "" Then _SetStatus("Connecting to " & $GlobalQuestURL & $tSearchParam) ;//Onu is meditating ;$tQuestResSource = _INetGetSource ($GlobalQuestURL & $tSearchParam) $tQuestResSource = _INetGetSource ($GlobalQuestURL & "Onu is meditating") _SetStatus("Retrieved data from " & $GlobalQuestURL & $tSearchParam) If StringInStr ($tQuestResSource, "No search results found.") Then GUICtrlSetData ($GUILblQuestDescription, "No search results found.") Else MsgBox (32, "test", $tQuestResSource) EndIf EndIf EndFunc Anyone want to give me a hand / point in the direction? Edited February 13, 2009 by Dampe Link to comment Share on other sites More sharing options...
James Posted February 13, 2009 Share Posted February 13, 2009 Why this?"http:http://thottbot.com/?s="Should it not be:"http://thottbot.com/?s="? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Robjong Posted February 13, 2009 Share Posted February 13, 2009 (edited) I'm trying to parse raw html into a big string, just leaving the important things behind. What are those important things? This just strips all HTML tags, leaving the text unchanged. Global $oMyError = ObjEvent("AutoIt.Error", "COMError") InetGet("http://thottbot.com/?s=", @ScriptDir & "\html.html") $sSource = FileRead(@ScriptDir & "\html.html") $sPlainText = _HTML_StripTags($sSource) ConsoleWrite($sPlainText & @CRLF) Func _HTML_StripTags($sHTML) If Not StringStripWS($sHTML, 8) Then Return SetError(1, 0, "") Local $oHTML = ObjCreate("HTMLFILE") If @error Then Return SetError(2, 0, "") $oHTML.Open() $oHTML.Write($sHTML) If Not $oHTML.Body.InnerText Then Return SetError(3, 0, "") Return SetError(0, 0, $oHTML.Body.InnerText) EndFunc ;==>_HTML_StripTags Func COMError() MsgBox(16, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) EndFunc ;==>COMError Edited February 13, 2009 by Robjong Link to comment Share on other sites More sharing options...
Dampe Posted February 13, 2009 Author Share Posted February 13, 2009 Why this? Should it not be: ?Yep. Accident, only put that there on the forum so people knew what I was trying to do What are those important things? This just strips all HTML tags, leaving the text unchanged. Global $oMyError = ObjEvent("AutoIt.Error", "COMError") InetGet("http://thottbot.com/?s=", @ScriptDir & "\html.html") $sSource = FileRead(@ScriptDir & "\html.html") $sPlainText = _HTML_StripTags($sSource) ConsoleWrite($sPlainText & @CRLF) Func _HTML_StripTags($sHTML) If Not StringStripWS($sHTML, 8) Then Return SetError(1, 0, "") Local $oHTML = ObjCreate("HTMLFILE") If @error Then Return SetError(2, 0, "") $oHTML.Open() $oHTML.Write($sHTML) If Not $oHTML.Body.InnerText Then Return SetError(3, 0, "") Return SetError(0, 0, $oHTML.Body.InnerText) EndFunc ;==>_HTML_StripTags Func COMError() MsgBox(16, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) EndFunc ;==>COMError Thanks, hopefully I'll be able to do something from there. Link to comment Share on other sites More sharing options...
StrategicX Posted February 13, 2009 Share Posted February 13, 2009 Well, I see your just trying to get a certain string out of the a thottbot.com page for wow info... See I made a model edit project a while back, and it would search thottbot.com for a certain item's ID # So the user could model edit their appearance of the weapon/item they wanted.. And since theres alot of un-useful info in all that HTML I found a great function that i used to parse HTML data from _INETGetSource() function which would find a certain string between 2 known parameters.. Basicly the modded StringBetween function... But since the original string between function is stupid because you need to know the string your searching for lol This one is perfect! Heres the Modded Function I use to parse HTML.. Func _StringBetween2($s, $from, $to) $x = StringInStr($s, $from) + StringLen($from) $y = StringInStr(StringTrimLeft($s, $x), $to) Return StringMid($s, $x, $y) EndFunc ;==>_StringBetween and Heres an example of using it... $THOTTBOT = _INetGetSource("Http://www.thottbot.com/") $String = _StringBetween2($THOTTBOT, "<Title>", "</Title>") MsgBox(1, "ThottBot.com", $String) See how that works? Just a simple example but it parses the HTML source very fast and in that small example... It will return $String as Thottbot: World of Warcraft in a MsgBox() .. This is just a simple example but can be used to parse multiple strings , no matter how big the source... plus Thottbot source pages arent to big anywayz... Enjoy and good luck *WoW Dev Projects: AFK Tele Bot development journalSimple Player Pointer Scanner + Z-Teleport*My Projects: coming soon.Check out my WoW Dev wiki for patch 3.0.9!http://www.wowdev.wikidot.com 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