求助ESP8266为什么获取不到XML
#include <ESP8266WiFi.h>#include <ESP8266HTTPClient.h>
char ssid[] = "GTWY1";// WiFi名 SSID (name)
char pass[] = "58025952"; // WiFi密码
const unsigned long BAUD_RATE = 115200;//**
String payload = ""; //获取数据储存变量
String webadd = "http://wthrcdn.etouch.cn/WeatherApi?citykey=101010100"; //接口地址
int time1 = 0;//WIFI等待时间(500ms)
int sta,sta2;
String com;
void setup()
{
delay(1000);
Serial.begin(BAUD_RATE);//**
WiFi.begin(ssid, pass);//连接WIFI
}
void loop(){
http();
}
/*****************************************http数据获取*******************************************/
void http(){
HTTPClient http;
http.begin(webadd);
int httpCode = http.GET();//返回的代号200为正常
if(httpCode > 0) {
payload = http.getString();//获取XML数据
int a = payload.indexOf("shidu");
com = payload.substring(a,a+12);
Serial.println(payload);//**
Serial.println(httpCode);//**
Serial.println(com);//**
Serial.println(a);//**
// }
}
http.end();
}
谢谢帮助
页:
[1]