using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Net; using System.IO; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string appid = "983506039_qq_com_962b1aefc"; string appkey = "2e0b9a8a2f357d2f2901055b290c185ad56196e714bb127d4a09e4b81b7c"; // string jsonHeard = "{\"app_id\": \""+ appid+"\", \"app_key\": \""+ appkey+"\"}"; string url = "https://api.mathpix.com/v3/text"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/json"; request.Headers.Set("app_id", appid); request.Headers.Set("app_key", appkey); string body = "{ \"src\":\"https://mathpix-ocr-examples.s3.amazonaws.com/cases_hw.jpg\", \"math_inline_delimiters\": [\"$\", \"$\"], \"rm_spaces\": True}"; body = "{ \"src\":\"http://www.dotnetcms.cn/1.png\", \"math_inline_delimiters\": [\"$\", \"$\"], \"math_display_delimiters\": [\"$$\", \"$$\"], \"rm_spaces\": \"true\"}"; byte[] postBytes = null; postBytes = Encoding.UTF8.GetBytes(body); request.ContentLength = postBytes.Length; using (Stream reqStream = request.GetRequestStream()) { reqStream.Write(postBytes, 0, postBytes.Length); } string result = string.Empty; using (WebResponse response = request.GetResponse()) { if (response != null) { using (Stream stream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { result = reader.ReadToEnd(); } } } } Response.Write(result); } }