Created
July 13, 2013 04:53
-
-
Save leegao/5989463 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import json | |
headers = { | |
'Host': 'webdemo.visionobjects.com', | |
'Connection': 'keep-alive', | |
'Accept': 'equation/json', | |
'Origin': 'http://webdemo.visionobjects.com', | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36', | |
'Content-type': 'application/x-www-form-urlencoded', | |
'Referer': 'http://webdemo.visionobjects.com/', | |
'Cookie': 'WebDemoPortalWarning=1; __utma=182204193.640085604.1373662884.1373662884.1373662884.1; __utmb=182204193.3.10.1373662884; __utmc=182204193; __utmz=182204193.1373662884.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)' | |
} | |
strokes = [ | |
# xs ys | |
[[0],[0]], | |
[[0],[0]] | |
] | |
def makeStroke(xys): | |
return {"y": xys[1], "x": xys[0], "type": "stroke"} | |
input = {"resultTypes": ["LATEX"], "components": map(makeStroke, strokes)} | |
data = {'equationInput': json.dumps(input), 'application': 'webdemo.equation', 'apiKey': 'f3469740-d247-11e1-acbf-0025648c5362'} | |
data = urllib.urlencode(data) | |
url = 'http://webdemo.visionobjects.com/webservices/api/myscript/v2.0/equation/doSimpleRecognition.json' | |
req = urllib2.Request(url, data, headers) | |
response = urllib2.urlopen(req) | |
print response.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment