html - 尝试在 App Store 上获取我的应用程序页面的 HTML 源代码

标签 html ios cocoa cocoa-touch

我想使用这段代码在应用商店中解析我自己的应用的页面

  NSError *error = nil;

  NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/id892887222?ls=1&mt=8"];

  NSStringEncoding encoding;
  NSString *webData= [NSString stringWithContentsOfURL:url
                                              encoding:encoding
                                                 error:&error];

webData 为 nil,[error localizedDescription] 显示无法打开文件“id892887222”。

我想发生这种情况是因为这个页面是动态的,是通过拉取数据库即时创建的,但是我如何获得这个页面的源代码?

最佳答案

此代码将页面的 HTML 作为 NSString 对象提供给我:

NSStringEncoding encoding;
NSError *error;
NSString *contentsOfAppleComAsString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/id892887222?ls=1&mt=8"] usedEncoding:&encoding error:&error];
if(contentsOfAppleComAsString)
{
    NSLog(@"contents of Apple.com is %@", contentsOfAppleComAsString);
} else {
    NSLog(@"error from trying to get contents of Apple.com is %@", [error localizedDescription]);
}

关于html - 尝试在 App Store 上获取我的应用程序页面的 HTML 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26534015/

相关文章:

arrays - 将自定义数组保存到 Core Data 中

php - 根据MySQL数据库记录的ID创建文件结构

ios - 无法从 iOS 中的 BLE 设备获取数据/服务

ios - 如何从 UITests 中访问 UITabBarItem?

objective-c - 如何使用 Objective-C 获取正在运行的进程

objective-c - 绑定(bind)和有条件设置隐藏

c# - 从 Input 控件获取数据到代码隐藏

javascript - 无法返回单击元素 Javascript 的值

javascript - 带有按钮的面板不会出现在 trumbowyg 插件上

ios - Xcode 11.1 中未显示等宽选项