Android Web请求内容格式
我想格式化从特定网站获得的内容以将其显示在我的设备上。例如,在此页面中,我只需要节目标题和每个节目的描述。我使用此函数获取此页面的 html 代码:
private String getPage() {
String str = "***";
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("http://golfnews.no/golfpaatv.php");
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
return str;
}
它返回一个包含 html 代码的字符串。现在我想要一些包含标题的字符串和包含描述的其他字符串。我尝试了一些方法,但我不知道该怎么办!我是初学者,对android了解不多。请你帮助我好吗 ?谢谢。
I want to format the content I get from a specific website to show it on my device . For example , from this page I need only the program titles and the description of each one . I get the html code for this page with this function :
private String getPage() {
String str = "***";
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("http://golfnews.no/golfpaatv.php");
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
return str;
}
It returns a string which contains the html code. Now I want to have some strings containing the titles and other strings containing the description . I tried a few methods but I can't figure out what to do ! I am a beginner and I don't know much in android . Could you please help me ? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需使用 此链接 获取 RSS,而不是使用该 URL,然后解析通过使用 SAX 解析器、DOM 解析器或 Pull 解析器来获取 RSS。
Instead of that URL, you just fetch RSS by using this link, and now parse the RSS either by using SAX Parser, DOM Parser or Pull Parser.