douying4909 2015-04-26 21:41
浏览 30

'CLOSED'从php网页获取HTML代码到android中的字符串

Note ** This is not a duplicate question ,it is unlike getting HTML code from html page

I have tried all the codes posted on this site that are used to get HTML code from a page into a string in android.But from all of the codes I've tried , non worked on a url of PHP webpage, for example (http://www.jonasweb.net/samples.php) . How can I do that ?

A sample code to get HTML source as string:

HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);

String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
    str.append(line);
}
in.close();
html = str.toString();
  • 写回答

1条回答 默认 最新

  • dongtu4028 2015-04-26 21:46
    关注

    You cannot access PHP source code, that would be like giving Jimmy Saville the key to an un-guarded orphanage. There are so many secure things, like database connections that are stored in PHP source, It just isn't happening.

    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口