【发布时间】:2020-10-04 07:32:27
【问题描述】:
我有一个正在使用 Expo 的 React Native 应用程序。
我正在使用库 react-native-rss-parser 来解析 xml RSS 提要并以 json 格式返回。它在大多数情况下运行良好。
但是,返回的 json 不返回缩略图或图像 url。
有一个名为“内容”的字段,它看起来像这样:
content: "<figure><img src='https://d36tnp772eyphs.cloudfront.net/blogs/1/2020/06/Black-Lives-Matter-protest-on-Alexanderplatz-Berlin.jpg' class='webfeedsFeaturedVisual'></figure><p><span style="text-transform:uppercase;">Protests sparked by</span> the murder of George Floyd <a href="https://matadornetwork.com/read/george-floyd-protests-worldwide/" target="_blank" rel="noopener noreferrer">haven’t just been contained to the United States</a>. This weekend, what is believed to be the largest turnout of Black Lives Matter protesters outside of the US took place in Germany. Over 15,000 protesters gathered in Alexanderplatz, in Berlin’s city center, in acknowledgment that racial discrimination..."
如何解析并获取 img src 网址?我真的只需要从content 获取这个:
我尝试了不同的 React Native HMTL 解析器和正则表达式,但都没有什么效果...
提前致谢!
【问题讨论】:
标签: javascript react-native rss html-parsing