webpro 31 Posted May 21, 2013 Author Report Share Posted May 21, 2013 Man i'm almost there ! This regex scrapes everything. \d\s.*\d\s The only thing missing is whatever the number isex:2 x 2 = works finebut if it's12 x 2 = 1 is missing So i need to make sure it can grab whatever the number is from 0 to 999, before and after any equation signs.I'll try to search this on G EDITED: So far this one seems to work for: .\w\d\s.*\d\s 1 x 1 (doesn't work)11 x 11 (works)111 x 111 (works)etc...( for division, multiplication, substraction, addition) So one digits ain't working.I'll try to update this thread as it could really help others. Quote Link to post Share on other sites
Pete 121 Posted May 21, 2013 Report Share Posted May 21, 2013 Try \d+ Quote Link to post Share on other sites
webpro 31 Posted May 22, 2013 Author Report Share Posted May 22, 2013 Thanks ZAP it's working 99% ! \d+\d\s.*\d\s This regex code grabs the equation on the entire page(last test)So it grabbed 12 + 12 COOL <form method="post"> <input type="hidden" name="id" value="1"> 12 + 12 = <input size="2" type="text" name="answer"> <br><br><input type="submit" name="submit" value="Submit"> </form> The page is pretty big by the way but it grabs another thing and i just can't get ride of it (so debugger shows 12 +12 and this below). It's not even close to the equation. Click 10 of <u>Each</u> everyday and <a href="bonus.php"><font color="blue">Claim bonus</font></a> 100 Do you know how to get ride of this line please ?Thanks Quote Link to post Share on other sites
VaultBoss 310 Posted May 22, 2013 Report Share Posted May 22, 2013 I'm not sure what you are trying to accomplish, but if I'm right and you seek to scrape the math equation from the FORM on that page, here is the UBS code to do that: set(#equation, $scrape attribute(<outerhtml=w"<form method=\"post\">*</form>">, "outertext"), "Global") After that, you can play with the string #equation and do whatever you want with it. In any case, it will only scrape that type of text within the form on the page and no other strange things. Hope this helps you.Cheers! Quote Link to post Share on other sites
webpro 31 Posted May 22, 2013 Author Report Share Posted May 22, 2013 Well i'm trying hard to create a regex that will grab anykind of math equations as it looks like i can't scrape some using UB's straight commands. Also, i noticed that it doesn't output the right solution ?Ex:This set(#answer, $eval($trim($replace(#mathquestion, "=", $nothing))), "Global") type text(<name="answer">, #answer, "Standard") set(#mathquestion, $scrape attribute(<outerhtml=w"<form method=\"post\">*</form>">, "outertext"), "Global") used to scrape this: <form method="post"> <input type="hidden" name="id" value="5"> 8 x 8 = <input size="2" type="text" name="answer"> <br><br><input type="submit" name="submit" value="Submit"> </form> Gave "1" as result ???? Now i ain't good at math but i know it's wrong hehehehehe Also looks like substractions aren't working as this: <form method="post"> <input type="hidden" name="id" value="2"> 98 - 8 = <input size="2" type="text" name="answer"> <br><br><input type="submit" name="submit" value="Submit"> </form> Didn't give any result. Another ex. <form method="post"> <input type="hidden" name="id" value="1"> 12 + 10 = <input size="2" type="text" name="answer"> <br><br><input type="submit" name="submit" value="Submit"> </form> gave me "90" ? I will try a few things but it seems that the more i try, the worst it gets lol !!!! Thanks guys by the way Quote Link to post Share on other sites
VaultBoss 310 Posted May 22, 2013 Report Share Posted May 22, 2013 The code I gave you only returns a string text that is the written form of the equation. You have to take it from there and extract the operators (numbers) and operands (math ops, like +, -, *, /) and use them in a JavaScript $eval to get the correct answer. Another way would be to just ask Google (copy/paste the math equation string into a Google search box) and you will get the answer. Quote Link to post Share on other sites
webpro 31 Posted May 22, 2013 Author Report Share Posted May 22, 2013 I see... I never thought about using something online to solve. Thanks !!! As i wanted to catch this also using Regex, well i finally made it.So here it is for everyone to see. If you got math captchas like this one <form method="post"> <input type="hidden" name="id" value="9"> 2 x 7 = <input size="2" type="text" name="answer"> <br><br><input type="submit" name="submit" value="Submit"> </form> Then use this regex to grab the equations (works with any number of digits and with multiplications and substractions too) \d+\s.\s\d+ Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.