1
我怎樣才能得到一個網站的HTML與retrofit
?獲取帶翻新網站的HTML - Android?
例如我有這個url,我需要得到這個URL的HTML,我怎麼能加載更多。
貝婁是我的代碼:
MainActivity.java:
public class MainActivity extends AppCompatActivity {
TextView txt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (TextView) findViewById(R.id.txt);
OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://www.instagram.com/elde0596/")
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
final Interface_Web request = retrofit.create(Interface_Web.class);
Call<ResponseBody> call = request.getHtml();
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
txt.setText(response.body().source().toString());
Log.i("SDADASDAWEQ", "A " + response.body().toString());
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.i("SDADASDAWEQ", "B " + t.getMessage());
}
});
}
}
Interface_Web.java:
public interface Interface_Web {
@GET("/")
Call<ResponseBody> getHtml();
}
只是告訴我:
[size=9500 text=<!DOCTYPE html>\n<!--[if lt IE 7]> <html lang="en" class="no…]
但我需要查看全部html
。
請註明你嘗試過什麼,並在您的缺乏,並請在這裏把一些代碼 –