danmactough / node-feedparser

Robust RSS, Atom, and RDF feed parsing in Node.js
Other
1.97k stars 192 forks source link

i can't get the image url from article/item though other i can see it on xml #210

Closed iamanam closed 7 years ago

iamanam commented 7 years ago

i can't get the image url or the image object, while other can manage to get other options.

**if i use item.image then i get empty object. Also tired to see whats inside the object with for..in loop but doesn't get anything.

** if i use item.image.url then also get undefined.

Here is my codes.

can i try helping me out with this please?

const formatItem = function (item) {
  if (item && typeof item === 'object') {
    return {
      title: item.title,
      description: item.description || item['content:encoded'][1] || 'no description available',
      pubDate: item.pubDate,
      image: item.image.url || item.image
    }
  }
  console.log('item feeds cant be formatted')
}

fetchXml(sourceUrl).then(body => {
    body
      .pipe(new Feedparser())
      .pipe(through2.obj(function (chunk, enc, callback) {
        console.log(chunk.image.url)
        this.push(formatItem(chunk))
        callback()
      }))
   ....
diego-suarez commented 7 years ago

Facing the same problem. When querying the feed with curl, it contains a field on the article like: <g:image_link>http://www.example.com/image1.jpg</g:image_link> But the library returns an empty object on the image field.

danmactough commented 7 years ago

@iamanam What feed?

martinmurciego commented 4 years ago

I could see that in the Mailtrain tool that uses this module: it includes the featured image along with the summary when I use a Wordpress plugin to include it in the RSS Feed. `

El 18 de febrero se realizará la Jornada Internacional de Enfermería Familiar y Comunitaria
    <link>https://salud.misiones.gob.ar/el-18-de-febrero-se-realizara-la-jornada-internacional-de-enfermeria-familiar-y-comunitaria/</link>
            <pubDate>Mon, 10 Feb 2020 16:44:22 +0000</pubDate>
    <dc:creator><![CDATA[Jonatan]]></dc:creator>
            <category><![CDATA[Noticias]]></category>

    <guid isPermaLink="false">https://salud.misiones.gob.ar/?p=15464</guid>
            <description><![CDATA[<img width="150" height="150" src="https://salud.misiones.gob.ar/wp-content/uploads/2020/02/jornadas-internacional-de-enfermeria-1-150x150.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="display: block; margin-bottom: 5px; clear:both;max-width: 100%;" link_thumbnail="" />El 18 de febrero, a partir de las 8 horas, se realizará la Jornada Internacional de Enfermería Familiar y Comunitaria en el salón auditorio de la Escuela de Enfermería de la UNaM. En este encuentro disertaran las Enfermeras Ana Romero García, Residente de Enfermería Familiar y Comunitaria de la Unidad Docente de Girona ICS- España. [&#8230;]]]></description>`