Android开发人员:我如何提取网页数据,并使用这些数据在我的应用程序? [英] Android Dev: How do I extract data from the web and use the data in my app?

查看:132
本文介绍了Android开发人员:我如何提取网页数据,并使用这些数据在我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这个Android应用程序称为歌词应用程序。它提供了当前播放歌曲的歌词,但需要互联网连接始终。现在,我想做一个类似的应用程序,它会从网上首次歌词,然后将其保存到我的Andr​​oid设备,以便下一次歌曲播放,它会从设备的歌词,而不是网络的..不再需要不断的互联网连接。

I saw this android app called Lyrics App. It provides the lyrics of the song currently played but needs internet connection always. Now, I wanted to make a similar app, that it gets the lyrics from the web for the first time and then saves it to my android device, so that next time a song is played, it'll get the lyrics from the device instead of the web.. no need for constant internet connection.

我已经搜查,但我无法找到合适的人对我的情况。我检查web视图,但我认为这只是用于显示的WebContent,没有解压。

I've searched already but I can't find the right one for my case. I checked webview, but I think it's just for displaying webcontent, not extracting.

我是新来这个,所以请多多包涵。

I am new to this, so please bear with me.

推荐答案

试试...

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://www.someplace.com");
ResponseHandler<String> resHandler = new BasicResponseHandler();
String page = httpClient.execute(httpGet, resHandler);

这可以用来抓取整个网页作为一个字符串的HTML,即&LT; HTML&GT; ...&LT; / HTML&gt;中

This can be used to grab the whole webpage as a string of html, i.e., "<html>...</html>"

编辑:注意,你需要声明下面的使用,允许在Android清单xml文件...

Note, you need to declare the following 'uses-permission' in the android manifest xml file...

<uses-permission android:name="android.permission.INTERNET" />

这篇关于Android开发人员:我如何提取网页数据,并使用这些数据在我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆