12345678910111213141516171819202122232425262728293031323334 |
- package ocr
- import (
- "io"
- "net/http"
- "net/url"
- "strings"
- "time"
- )
- func GetCaptchaCodeF(imgPath string, comID uint, len int) string {
- var client = http.Client{}
- client.Timeout = time.Duration(time.Second * 10)
- tyURL := "http://111.231.60.74:5088/check"
- bstr, err := base64Img(imgPath)
- if err != nil {
- return ""
- }
- params := "recognize_img=" + url.QueryEscape(bstr)
- req, err := http.NewRequest("POST", tyURL, strings.NewReader(params))
- if err != nil {
- return ""
- }
- req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
- resp, err := client.Do(req)
- if err != nil {
- return ""
- }
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return ""
- }
- return string(body)
- }
|