我想知道是否有一种方法可以像抓取xml文件一样抓取html文件中的内容。例如,使用xml文件,我可以在抓取内容时创建一个httpclient,如下所示:
var metaDataURL="some_xmlfile";
var xhr=Titanium.Network.createHTTPClient();
xhr.open('GET',metaDataURL);
xhr.send();
xhr.onload=function(){
alert("loaded");
}
xhr.onerror = function(e) {
alert(e.error);
};
我需要的信息的url是:
http://50.7.242.154:8070/7.html
里面只有一些数字和一首歌的名字和艺术家的名字。我有没有办法做到这一点?
发布于 2013-08-30 22:28:27
你以同样的方式使用它,你只需要从服务器获取文件。本质上是下载。
var xhr=Titanium.Network.createHTTPClient({
onload : function(e) {
var htmlresponse = this.responseText;
// Do what you want with the HTML now
}
});
xhr.open('GET','http://50.7.242.154:8070/7.html');
xhr.send();
https://stackoverflow.com/questions/18534240
复制相似问题