[英]Getting table generated by javascript from HTML with Objective-C
I am trying to develop an app that needs to get data from a table on a website, the problem is that I need to get the HTML of the table after the javascript function has run but I've had no success with it so far. 我正在尝试开发一个需要从网站上的表中获取数据的应用程序,问题是我需要在javascript函数运行后获取表的HTML,但到目前为止我还没有成功。
The website is www.mylocalcrime.com. 该网站是www.mylocalcrime.com。 What I currently have the application doing is, 我目前正在让应用程序执行的操作是
Any ideas would be greatly appreciated. 任何想法将不胜感激。
Thanks 谢谢
Its really simple. 真的很简单。 Check out the page code, and you will find a javascript file called "my_local_crime.js". 检出页面代码,您将找到一个名为“ my_local_crime.js”的javascript文件。 This is the heart of the data you get from the site. 这是您从网站获得的数据的核心。 When you get to the code lines 164-169 in this document, you get the following javascript code: 当您到达本文档中的代码行164-169时,您将获得以下javascript代码:
var url = "http://api.spotcrime.com/crimes.json?";
url += "lat="+center.lat();
url += "&lon="+center.lng();
url += "&radius="+radius;
url += "&callback=?";
url += "&key=MLC-restricted-key";
This is how the javascript on the page generates the JSON query. 这是页面上的javascript生成JSON查询的方式。 You can do the same within objective-c, create the correct query, and get JSON data from api.spotcrime.com instead of going via mylocalcrime.com. 您可以在Objective-C中执行相同的操作,创建正确的查询,并从api.spotcrime.com获取JSON数据,而无需通过mylocalcrime.com。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.