ESP8266通过WIFI获取IP和定位的问题

问题遇到的现象和发生背景:Arduino ESP8266通过WIFI联网,想通过IP138获取本机IP和定位。但是报错400。
相关代码:
void ip138(){
  std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
  //client->setFingerprint(fingerprint);
  // 或者,如果您愿意忽略SSL证书,请使用以下行:
  client->setInsecure();
  
  if (http.begin(espClient, "https://2021.ip138.com/")) {  // HTTP
    Serial.print("[HTTP] GET...\n");
    // start connection and send HTTP header
    int httpCode = http.GET();

    // httpCode will be negative on error
    if (httpCode > 0) {
      // HTTP header has been send and Server response header has been handled
      Serial.printf("[HTTP] GET... code: %d\n", httpCode);

      // file found at server
      if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
        String htmlcode = http.getHtml();
        String bstr="";
        String estr="";
        bstr="?ip=";
        estr="&amp";
        int indexStart = htmlcode.indexOf(bstr);//特征码1起始位置
        int endIndex =htmlcode.indexOf(estr);//特征码2位置
        int beglen=bstr.length();//特征码1的长度
        myip = htmlcode.substring(indexStart+beglen,endIndex);//此函数的意义要理解
        Serial.println(myip);
        bstr="来自:";
        estr=" 移动";
        indexStart = htmlcode.indexOf(bstr);//特征码1起始位置
        endIndex =htmlcode.indexOf(estr);//特征码2位置
        beglen=bstr.length();//特征码1的长度
        myaddress = htmlcode.substring(indexStart+beglen,endIndex);//此函数的意义要理解
        Serial.println(myaddress);
      }
    } else {
      Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
    }
    http.end();
  } else {
    Serial.printf("[HTTP} Unable to connect\n");
  }
}

######报错内容:
[HTTP] GET...
[HTTP] GET... code: 400

我的解答思路和尝试过的方法:

目前想不到解决的办法。

我想要达到的结果:

模块连网后自动获取本地公网IP和相应地址(精确到区县级),目前看了一下就https://2021.ip138.com/ (到2022年是不是会变成https://2022.ip138.com)和 https://ipchaxun.com/ 这两个网站能够精确到区县级。但是我太业余,连IP138都搞不定,https://ipchaxun.com/ 更不知道怎么搞。能否请您帮忙给个例程?