Android开发人员:我如何提取网页数据,并使用这些数据在我的应用程序?我的、数据、开发人员、应用程序

2023-09-05 11:28:00 作者:纵有南风起

我看到这个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" />
 
精彩推荐
图片推荐