gpt4 book ai didi

javascript - iOS - 从网站上的 javascript 中的 id 将图像加载到 UIImageView

转载 作者:行者123 更新时间:2023-11-29 03:33:49 24 4
gpt4 key购买 nike

我只是想知道是否可以从网站上提取 id“album_cover”。我需要将其加载到 UIImageView 中。我还应该提到,代码中的链接并不总是相同的,并且会随着歌曲的变化而变化( Link to what website i'm referring to ),所以这就是为什么我不能只获取 URL 并完成。

我想我也许可以使用我的代码 stringByEvaluatingJavaScriptFromString:@"document.getElementById('album_cover').textContent;" 但我不知道如何将其加载到 UIImageView

以下是来自网站的图像数据:

<div id="album_cover">
<img height="160px" width="160px" id="imgcover" src="http://api.cloudrad.io:8000/art/18a4c00346bccf046900f578b36bd2a5.png?nocache=2" alt="Loading...">
</div>

谢谢!

最佳答案

简而言之,您可能想要:

  1. 解析元素字符串得到URL字符串
  2. 使用[NSData dataWithContentsOfURL:]获取图片数据
  3. 使用[UIImage imageWithData:]创建UIImage对象
  4. 使用新图像设置 UIImageViewimage 属性

关于javascript - iOS - 从网站上的 javascript 中的 id 将图像加载到 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19438071/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com