Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ydclient: fix new api fetch #39

Merged
merged 2 commits into from
Nov 6, 2023
Merged

Conversation

eatradish
Copy link
Contributor

Before:

[2023-11-03T08:50:30Z DEBUG reqwest::async_impl::client] redirecting 'https://fanyi.youdao.com/openapi.do?keyfrom=ydcv-rs&key=1323298384&type=data&doctype=json&version=1.1&q=%E6%88%91' to 'http://fanyi.youdao.com/error.html'
[2023-11-03T08:50:30Z DEBUG reqwest::connect] starting new connection: http://fanyi.youdao.com/
[2023-11-03T08:50:30Z DEBUG ydcv_rs::ydclient] Recieved JSON <!DOCTYPE html>
    <html lang="" class="light">
    
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width,initial-scale=1.0">
      <meta name="keywords" content="在线即时翻译、免费AI翻译、文档文本翻译、人工翻译、网页翻译">
      <meta name="description"
        content="有道翻译提供即时免费的中文、英语、日语、韩语、法语、德语、俄语、西班牙语、葡萄牙语、越南语、印尼语、意大利语、荷兰语、泰语全文翻译、网页翻译、文档翻译、PDF翻译、DOC翻译、PPT翻译、人工翻译、同传等服务。">
      <link rel="icon" href="https://ydlunacommon-cdn.nosdn.127.net/31cf4b56e6c0b3af668aa079de1a898c.png">
      <title>有道翻译_文本、文档、网页、在线即时翻译</title>
    </head>
    
    <body>
      <noscript>
        <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
            Please enable it to continue.</strong>
      </noscript>
      <div id="app" class="index">
        <div class="content">
          <img src='https://ydlunacommon-cdn.nosdn.127.net/d02da5fd023f5474025e391efb03907c.png' class="feed">
          <a href="https://fanyi.youdao.com" class="return"></a>
        </div>
      </div>
    </body>
    
    </html>
    <style type="text/css">
      html,
      body,
      div,
      img {
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 100%;
        font: inherit;
        vertical-align: baseline;
        height: 100%;
      }
    
      .index {
        width: 100%;
        height: 100%;
        /* 加载背景图 */
        background: url("https://ydlunacommon-cdn.nosdn.127.net/15dab0042cf3fe2e02744fb58bbe1ad4.png") no-repeat;
        background-size: 100%, 100%;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    
      .content {
        width: 406px;
        height: 453px;
        display: block;
        position: relative;
      }
    
      .return {
        width: 100%;
        height: 44px;
        display: block;
        position: absolute;
        bottom: 0;
      }
    </style>
Error looking-up word 我: Error("expected value", line: 1, column: 1)

After:

[2023-11-03T08:57:29Z DEBUG reqwest::connect] starting new connection: http://fanyi.youdao.com/
[2023-11-03T08:57:29Z DEBUG reqwest::connect] proxy(http://127.0.0.1:7890) intercepts 'http://fanyi.youdao.com/'
[2023-11-03T08:57:29Z DEBUG ydcv_rs::ydclient] Recieved JSON <!DOCTYPE html>
    <html lang="" class="light">
    
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width,initial-scale=1.0">
      <meta name="keywords" content="在线即时翻译、免费AI翻译、文档文本翻译、人工翻译、网页翻译">
      <meta name="description"
        content="有道翻译提供即时免费的中文、英语、日语、韩语、法语、德语、俄语、西班牙语、葡萄牙语、越南语、印尼语、意大利语、荷兰语、泰语全文翻译、网页翻译、文档翻译、PDF翻译、DOC翻译、PPT翻译、人工翻译、同传等服务。">
      <link rel="icon" href="https://ydlunacommon-cdn.nosdn.127.net/31cf4b56e6c0b3af668aa079de1a898c.png">
      <title>有道翻译_文本、文档、网页、在线即时翻译</title>
    </head>
    
    <body>
      <noscript>
        <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
            Please enable it to continue.</strong>
      </noscript>
      <div id="app" class="index">
        <div class="content">
          <img src='https://ydlunacommon-cdn.nosdn.127.net/d02da5fd023f5474025e391efb03907c.png' class="feed">
          <a href="https://fanyi.youdao.com" class="return"></a>
        </div>
      </div>
    </body>
    
    </html>
    <style type="text/css">
      html,
      body,
      div,
      img {
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 100%;
        font: inherit;
        vertical-align: baseline;
        height: 100%;
      }
    
      .index {
        width: 100%;
        height: 100%;
        /* 加载背景图 */
        background: url("https://ydlunacommon-cdn.nosdn.127.net/15dab0042cf3fe2e02744fb58bbe1ad4.png") no-repeat;
        background-size: 100%, 100%;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    
      .content {
        width: 406px;
        height: 453px;
        display: block;
        position: relative;
      }
    
      .return {
        width: 100%;
        height: 44px;
        display: block;
        position: absolute;
        bottom: 0;
      }
    </style>
[2023-11-03T08:57:29Z DEBUG ydcv_rs::ydclient] url: https://openapi.youdao.com/api?appKey=7259e0df575e0a61&q=%E6%88%91&from=auto&to=EN&salt=16193&sign=ccf21efe46fcb1653b757f167df7e13b094de6063c50bd8a7da31e17213ba168&signType=v3&curtime=1699001849
[2023-11-03T08:57:29Z DEBUG reqwest::connect] starting new connection: https://openapi.youdao.com/
[2023-11-03T08:57:29Z DEBUG reqwest::connect] proxy(http://127.0.0.1:7890) intercepts 'https://openapi.youdao.com/'
[2023-11-03T08:57:29Z DEBUG rustls::client::hs] No cached session for DnsName(DnsName(DnsName("openapi.youdao.com")))
[2023-11-03T08:57:29Z DEBUG rustls::client::hs] Not resuming any session
[2023-11-03T08:57:29Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
[2023-11-03T08:57:29Z DEBUG rustls::client::tls13] Not resuming
[2023-11-03T08:57:29Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [ServerNameAck, Protocols([6832])]
[2023-11-03T08:57:29Z DEBUG rustls::client::hs] ALPN protocol is Some(b"h2")
[2023-11-03T08:57:29Z DEBUG rustls::client::tls13] Ticket saved
[2023-11-03T08:57:29Z DEBUG rustls::client::tls13] Ticket saved
[2023-11-03T08:57:29Z DEBUG ydcv_rs::ydclient] Recieved JSON {
      "query": "我",
      "errorCode": "0",
      "translation": [
        "I"
      ],
      "basic": {
        "explains": [
          "I",
          "me",
          "myself"
        ],
        "phonetic": "wǒ",
        "us_phonetic": null,
        "uk_phonetic": null
      },
      "web": [
        {
          "key": "我爱她",
          "value": [
            "And l love her"
          ]
        },
        {
          "key": "无我",
          "value": [
            "Anatta",
            "anatman",
            "no-self"
          ]
        },
        {
          "key": "我宣誓",
          "value": [
            "I SWEAR",
            "I took an oath"
          ]
        }
      ]
    }
我 [wǒ] I
  Word Explanation:
     * I
     * me
     * myself
  Web Reference:
     * 我爱她       And l love her
     * 无我       Anatta;anatman;no-self
     * 我宣誓       I SWEAR;I took an oath

Copy link
Owner

@farseerfc farseerfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多謝!

@farseerfc farseerfc merged commit 0017c91 into farseerfc:master Nov 6, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants