2013-05-07 85 views
-2

如何访问网站并将网站组件转换为字符串。例如从Facebook的帖子中获取信息。我已经做了一些搜索,但找不到任何好的教程或任何有用的东西。将网页源代码转换为NSString

+0

获取一个HTML解析器 – Kevin 2013-05-07 00:23:22

+0

所以解析HTML,写入文件的应用程序可以访问,然后呢? – 2013-05-07 00:30:49

+1

使用+(id)stringWithContentsOfURL:(NSURL *)url编码:(NSStringEncoding)enc error:(NSError **)error'将想要解析的网页下载到'NSString'中,然后将其传递给HTML解析器并提取您感兴趣的元素。 – Kevin 2013-05-07 00:43:24

回答

1

试试看本教程。它应该让你更加熟悉这个主题,并在正确的轨道上开始你。

因为它在教程开始状态...

How to Parse HTML on iOS

Let’s say you want to find some information inside a web page and display it in a custom way in your app. This technique is called “scraping.” Let’s also assume you’ve thought through alternatives to scraping web pages from inside your app, and are pretty sure that’s what you want to do. Well then you get to the question – how can you programmatically dig through the HTML and find the part you’re looking for, in the most robust way possible? Believe it or not, regular expressions won’t cut it! Well, in this tutorial you’ll find out how! You’ll get hands-on experience with parsing HTML into an Objective-C data model that your apps can use.

http://www.raywenderlich.com/14172/how-to-parse-html-on-ios

+0

完美!谢谢! – 2013-05-07 03:42:34

+0

如果您可以总结链接页面,这将是一个更好的答案。就目前而言,如果页面移动或消失,这个答案将毫无用处。 – Caleb 2013-05-07 12:55:56