如何解析网页源以获取数组的值
我正在尝试在 ipod 上实现一个乐透游戏,我需要解析实际的乐透页面以获取中奖号码,并将它们放入一个数组中,以将它们与用户输入的数字进行比较,并找出他是否是一个赢家与否。谁能帮我,因为 真的被困住了吗?
提前致谢! :)
I am trying to implement a lotto game on the ipod and i need to parse the actual lotto page to get the winning numbers and to put them in an array to compare them with the numbers that the user had entered and find out if he is a winner or not. Can anyone help me with it because
really am stuck with it?
Thanks in advance! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要的是一个 DOM 解析器,例如 Apple 的 NSXMLParser。
具体来说,您希望使用 XPath 解析来读取乐透页面 DOM 树上特定 DOM 节点的值。
由于 iOS 没有附带 NSXMLDocument(支持 XPath),您可能需要按照此处所述进行操作:
在 Cocoa 中使用 libxml2 进行 XML 解析和 XPath 查询
解析 XML/HTML 的其他解决方案:
如何选择最好的适用于您的 iPhone 项目的 XML 解析器
What you need is a DOM parser, such as Apple's NSXMLParser.
Specifically you'd want to use XPath parsing to read the value of a specific DOM node on your lotto page's DOM tree.
As iOS does not come with NSXMLDocument (which supports XPath), you'd probably need to do as described here:
Using libxml2 for XML parsing and XPath queries in Cocoa
Other solutions for parsing XML/HTML:
How To Choose The Best XML Parser for Your iPhone Project