【问题标题】:React Native (Expo) app — need to parse RSS feed to find url for img srcReact Native (Expo) 应用程序 - 需要解析 RSS 提要以找到 img src 的 url
【发布时间】: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 获取这个:

https://d36tnp772eyphs.cloudfront.net/blogs/1/2020/06/Black-Lives-Matter-protest-on-Alexanderplatz-Berlin.jpg

我尝试了不同的 React Native HMTL 解析器和正则表达式,但都没有什么效果...

提前致谢!

【问题讨论】:

    标签: javascript react-native rss html-parsing


    【解决方案1】:

    我建议你添加一个简单的正则表达式规则

    https.*?.jpg
    

    查找regex example

    【讨论】:

      猜你喜欢
      • 2016-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多