webview可以获取网页源码,进行重新排版吗
2012-07-18 18:39
330 查看
private void getHtml_data(String Url, int FontSize) {
String text = "";
try {
URL url = new URL(Url);
URLConnection conn;
conn = url.openConnection();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line = "";
String data = "";
while ((line = rd.readLine()) != null) {
Message lmsg;
lmsg = new Message();
lmsg.obj = line;
lmsg.what = 0;
data = data + (String) lmsg.obj;
}
text = data.replace("<body>", "<body style=\"font-size:" + FontSize
+ "px;\">");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myWebView.loadDataWithBaseURL("", text, "text/html", "UTF-8", null);
}
data就是你要的网页源码,text修改(就像我在body 加上size)
最后用myWebView.loadDataWithBaseURL("", text, "text/html", "UTF-8", null);
String text = "";
try {
URL url = new URL(Url);
URLConnection conn;
conn = url.openConnection();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line = "";
String data = "";
while ((line = rd.readLine()) != null) {
Message lmsg;
lmsg = new Message();
lmsg.obj = line;
lmsg.what = 0;
data = data + (String) lmsg.obj;
}
text = data.replace("<body>", "<body style=\"font-size:" + FontSize
+ "px;\">");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myWebView.loadDataWithBaseURL("", text, "text/html", "UTF-8", null);
}
data就是你要的网页源码,text修改(就像我在body 加上size)
最后用myWebView.loadDataWithBaseURL("", text, "text/html", "UTF-8", null);
相关文章推荐
- Android 在WebView中获取网页源码
- android 获取当前webview显示的网页的源码和网页中框架的源码
- 获取WebView加载的网页内容并进行动态修改
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- 获取WebView加载的网页内容并进行动态修改
- 在webview中获取网页源码
- 在WebView中获取网页源码
- Android:在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- android系列: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android:在WebView中获取网页源码
- iOS 基于JavaScriptCore 不等webView加载完毕就交互,网页获取原生内容。 webView的高级用法之JS交互,js与oc的相互调用
- Robotium源码解读-native控件/webview元素的获取和操作
- 获取某一个view所在视图控制器,进而可以进行跳转等操作