adroitful Posted June 12, 2009 Posted June 12, 2009 Is it possible to search or remove everything but a given tag. For example, <fieldset><legend>Equipment</legend> Item stats random item name +1 Lightning Damage </fieldset> Would it be possible to search thru just this part of the html for a specific statistic. Like say, I wanted to check if the item has +1 lightning damage and if not, have my autoit code trash it. I figure the best way would be to create a temp text file or something. Thanks again for any input on this. I hope this will be the last question I have to bother you guys with and i'm just stumped on this one.
Inverted Posted June 12, 2009 Posted June 12, 2009 (edited) You can use standard string functions. Example : #Include <string.au3> #Include <Array.au3> $string = "<fieldset> <legend>Equipment</legend>Item statsrandom item name+1 Lightning Damage </fieldset>" $array1 = _StringBetween($string, "<fieldset>", "</fieldset>") _ArrayDisplay($array1) Edited June 12, 2009 by Inverted
adroitful Posted June 12, 2009 Author Posted June 12, 2009 You can use standard string functions. Example : #Include <string.au3> #Include <Array.au3> $string = "<fieldset> <legend>Equipment</legend>Item statsrandom item name+1 Lightning Damage </fieldset>" $array1 = _StringBetween($string, "<fieldset>", "</fieldset>") _ArrayDisplay($array1) Wow, I had no idea that AutoIt had this kind of function built into it. Thanks for the quick and helpful reply. I'll mess with it and see if I can't get it to do what I want.
adroitful Posted June 13, 2009 Author Posted June 13, 2009 Okay, I've tried messing with what you've given me. I cannot get it to display the array though. Here's what I have: $string = "<fieldset> <legend>Equipment ( 4 / 8 )</legend> </fieldset>" $array1 = _StringBetween($string, "<legend>", "</legend>") _ArrayDisplay($array1,"Items:") Heres the page code: <fieldset><legend>Equipment ( 4 / 8 )</legend> <div class="ce"><!-- 20919875 --><div class="mpl fL"><img src="http://ladderslasher.d2jsp.org/icons/Club.gif"> <b> splintered club</b><br> Damage: 2 to 10<br> <br> <br><br><br><br></div><!-- 2078549 --><div class="mpl fL"><img src="http://ladderslasher.d2jsp.org/icons/Dagger.gif"> <b>Mystical mithril dagger</b><br> Level Req: 25<br> Damage: 46 to 80<br> <br> +25% Enhanced Effect<br>+5 Extra Item Slots<br>+1% Damage Return<br></div><!-- 20920775 --><div class="mpl fL"><img src="http://ladderslasher.d2jsp.org/icons/Dagger.gif"> <b>Mystical mithril dagger</b><br> Level Req: 25<br> Damage: 36 to 64<br> <br> +1 Magic Luck<br>+1% Block<br>+2% Mana Syphon<br></div><!-- 20918593 --><div class="mpl fL"><img src="http://ladderslasher.d2jsp.org/icons/LightCharm.gif"> <b>Magical lightning I</b><br> Spell Damage: 2 to 24<br> Mana Cost: 5<br><br> +1 to 10 Mana per Kill<br><br><br></div></div> </fieldset> <fieldset><legend>Items</legend> <div class="ce"><!-- 20797326 --><div class="mpl fL"><img src="http://ladderslasher.d2jsp.org/icons/Comfrey.gif"> <b>Magical comfrey</b><br> Level Req: 5<br> <desc>Use Item to Receive Effect</desc><br> <br> Heals 340 Life<br></div><!-- 20817938 --><div class="mpl fL"><img src="http://ladderslasher.d2jsp.org/icons/Comfrey.gif"> <b>Magical comfrey</b><br> <desc>Use Item to Receive Effect</desc><br> <br> Recovers 434 Mana<br></div></div> </fieldset> Basically, i'm trying to make it search the items and if they don't meet my expectations, i'll have my bot toss them. Hopefully I can get this working and as always any help would be greatly appreciated
DCCD Posted June 13, 2009 Posted June 13, 2009 #Include <string.au3> #Include <Array.au3> #include <Inet.au3> ; $array1 = _StringBetween(_INetGetSource ("http://www.autoitscript.com/forum/index.php?showtopic=96648"), "<title>", "</title>") _ArrayDisplay($array1) [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
adroitful Posted June 13, 2009 Author Posted June 13, 2009 #Include <string.au3> #Include <Array.au3> #include <Inet.au3> ; $array1 = _StringBetween(_INetGetSource ("http://www.autoitscript.com/forum/index.php?showtopic=96648"), "<title>", "</title>") _ArrayDisplay($array1) Okay, I tried changing my code to this and all I get is an error. It's not specifying anything in particular about it either: $string = "<fieldset> <legend>Equipment ( 4 / 8 )</legend> </fieldset>" $array1 = _StringBetween(_INetGetSource ("http://forums.d2jsp.org/user.php?c=3&i=564064&p=283765?"), "<legend>", "</legend>") _ArrayDisplay($array1,"Items:")
DCCD Posted June 13, 2009 Posted June 13, 2009 Don't change a thing! #Include <string.au3> #Include <Array.au3> #include <Inet.au3> ; $array1 = _StringBetween(_INetGetSource ("http://forums.d2jsp.org/user.php?c=3&i=564064&p=283765?"), "<legend>", "</legend>") _ArrayDisplay($array1,"Items:") [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
adroitful Posted June 13, 2009 Author Posted June 13, 2009 Okay, with a little tweaking of the code you gave me, I managed to get it to work. Then, I used _ArraySearch to search for different stats. Thanks very much, now I can go finish my program
adroitful Posted June 13, 2009 Author Posted June 13, 2009 (edited) N/m Edited June 13, 2009 by adroitful
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