ESP8266HTTPClientを使ってあげれば
httpであればProxy経由で取得するのは簡単でした。
httpsは一筋縄ではいかなそう(?)勉強中です。
単純なサンプルを載せておきます。
/*
* 単純にProxy経由でWEBページを取得するサンプル
*/
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
void setup() {
Serial.begin(115200);
Serial.println();
WiFi.mode(WIFI_STA);
WiFi.begin("SSID", "PASSWORD");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
// wait for WiFi connection
if((WiFi.status() == WL_CONNECTED)) {
HTTPClient http;
Serial.print("[HTTP] begin...\n");
//Proxyサーバを使う場合
http.begin("Proxy.server.ip",8080,"http://www.dmsk.com/pc/main-hw.html");
//Proxyサーバを使わない場合
//http.begin("http://www.dmsk.com/pc/main-hw.html");
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) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
delay(20000);
}
解説というほどのこともないですが、
35行目で、Proxyサーバのアドレス、ポート、開きたいページのURLを指定するだけです。