• MathPix


    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);
    
        }
    }
    

      

  • 相关阅读:
    Python中with用法详解
    SVM-支持向量机总结
    shell 脚本总结
    pycharm git 用法总结
    python小实例——tkinter实战(计算器)
    PyCharm 使用技巧
    博客园博文生成章节目录
    Chrome安装crx文件的插件时出现“程序包无效”
    Matplotlib pyplot中title() xlabel() ylabel()无法显示中文(即显示方框乱码)的解决办法
    Pandas-高级部分及其实验
  • 原文地址:https://www.cnblogs.com/mqingqing123/p/16006982.html
Copyright © 2020-2023  润新知