Sign in to follow this  
Followers 0
Medic873

Pull Math Answer

11 posts in this topic

Okay im using a website called wolframalpha.com Im sure you have heard of it.. Dose math problems online well I already have the code to submit a math question but Im not sure what to do to harvest the answer from the website here is my current code.

#include <IE.au3>

$Question = inputbox ("Question", "What is the math problem you would like our software to solve.");

$oIE = _IECreate ( "http://www.wolframalpha.com/input/?i=" & $Question )
_IELoadWait ($oIE);Waits for webpage to load
;then copy answer to $Answer
msgbox (1,"Answer", "The answer is " & $Answer);

but my problem is pulling the answer how do I do this....

Share this post


Link to post
Share on other sites



see first of all it puts it in a difrent spot every time it seems like a algebra problem with be called a solution because of many mathmatical reasons and a 2+2 problem with be called answer how can I pull all these and display them because they are also images so I cant copy them so how can I take the image url and display it in a msgbox

Share this post


Link to post
Share on other sites

I am also willing to use a diffrent website or whatever might finish this if you can find a script out here I am more then pron to use it I have been looking for the past hour or so and havnt found nothin

Share this post


Link to post
Share on other sites

I almost dont want to respond because you have bumped twice in an hour (try the edit button), nonetheless.

By subbing out the math characters with the HTML codes it seems to have the desired result returned first. and capturing that is easy enough. the example below performs the magic of addition.

#include <INet.au3>

$Question = inputbox ("Adding Machine", "What is the math problem you would like our software to solve.");

$URL = StringReplace ($Question , "+" , "%2B")

$Source = _inetgetsource ("http://www.wolframalpha.com/input/?i=" & $URL)

$AnswerArray = StringRegExp ($Source , 'id="i_0200_1" alt="(.*?)"' , 1)

msgbox (0, 'Answer' , $AnswerArray[0])

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Okay sorry about the bumping guess I should have edited it rather then post agian but enter something like 4x=4 and it returns a error how can I fix that.

Share this post


Link to post
Share on other sites

Okay sorry about the bumping guess I should have edited it rather then post agian but enter something like 4x=4 and it returns a error how can I fix that.

Maybe try the obvious thing.. like..

#include <INet.au3>

$Question = inputbox ("Adding Machine", "What is the math problem you would like our software to solve.");

$URL = StringReplace ($Question , "+" , "%2B")

$Source = _inetgetsource ("http://www.wolframalpha.com/input/?i=" & $URL)

If StringInStr($source, "Wolfram|Alpha doesn't know how to interpret your input.") Then
    MsgBox(0,"", "This program doesn't know how to interpret your input.")
Else
    $AnswerArray = StringRegExp ($Source , 'id="i_0200_1" alt="(.*?)"' , 1)

    msgbox (0, 'Answer' , $AnswerArray[0])
EndIf

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

just start handling the different characters

- such as the equal sign which is %3D

(edit::looks like it does tolerate '=' just fine tho)

and handling the results

- since the first return of 4x=4 is a graph stringregexp does not return an array, so if an array is not returned grab the second answer and return it.

#include <INet.au3>

$Question = inputbox ("Adding Machine", "What is the math problem you would like our software to solve.");

$URL = StringReplace ($Question , "+" , "%2B")

$URL1 = StringReplace ($URL , "=" , "%3D")

$Source = _inetgetsource ("http://www.wolframalpha.com/input/?i=" & $URL1)

$AnswerArray = StringRegExp ($Source , 'id="i_0200_1" alt="(.*?)"' , 1)

if not isarray($AnswerArray) Then

$AnswerArray = StringRegExp ($Source , 'id="i_0300_1" alt="(.*?)"' , 1)

Endif

msgbox (0, 'Answer' , $AnswerArray[0])
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

That doesn't solve my issue first of all I dont want it to tell the user that it couldn't solve it cause it can its just under a different web variable because its a solution not a answer.

Second that still returns a array error.lol

I just need it to find this url

http://www3.wolframalpha.com/Calculate/MSP/MSP786319e5fe95gc4e9979000039i99b220c7fa6c5?MSPStoreType=image/gif&s=33&w=500&h=23
[\code]

if you do the math problem 2x=4


            
                


    Edited  by Medic873
    
    

            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
iamtheky   

    
        
    
             633
    
        
    

        
            
                þヨⓡᅷ∈℃⊥
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             633
    
        
    

                4,004 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #9 · 
            Posted 
            
            
            
        
    

    


            
        
            my snippet pulls the answer for both variable problems you have supplied.


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
            




  
  
    ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Okay thank you im going to try and add some stuff and I will ask for help if need thank you so much I really have trouble working the inetget commands and this is has helped me greatly

Share this post


Link to post
Share on other sites

I just need it to find this url

http://www3.wolframalpha.com/Calculate/M...5?MSPStoreType=image/gif&s=33

if you do the math problem 2x=4

Then you just need to change the regex in the example iamtheky posted. like this:

#include <INet.au3>

$Question = inputbox ("Adding Machine", "What is the math problem you would like our software to solve.");

$URL = StringReplace ($Question , "+" , "%2B")

$URL1 = StringReplace ($URL , "=" , "%3D")

$Source = _inetgetsource ("http://www.wolframalpha.com/input/?i=" & $URL1)
$AnswerArray = StringRegExp ($Source , 'src="(.*?)" id="i_0200_1"' , 1)
if not isarray($AnswerArray) Then
$AnswerArray = StringRegExp ($Source , 'src="(.*?)" id="i_0300_1"' , 1)

Endif
msgbox (0, 'Answer' , $AnswerArray[0])

That still returns a array error.lol

Why is that a problem?

You should probably sign up for a free Wolfram ID, so you can use their interactive API though.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0