nodejs-web-scraper icon indicating copy to clipboard operation
nodejs-web-scraper copied to clipboard

Transform via getElementContent

Open LydiaF opened this issue 3 years ago • 1 comments

Hi @ibrod83,

Thank you so much for this package, it is extremely useful.

I have a feature suggestion: ability to return objects from getElementContent. This way we can keep the data together.

At the moment I'm doing this...

const x = new CollectContent('a[id="some_id"]', {
    name: 'x',
    getElementContent: (a, b, c) => {
      const href = c.attr('href').substr(7)
      const html = c.html()
      return `${html}___${href}` // would like to return { html, href }
    },
  })

Something unexpected happens when you try to return an object, you get what you would get if you didn't have the getElementContent option.

Thanks for considering!

Lydia

LydiaF avatar Jul 13 '22 09:07 LydiaF

Hey, I'm not really working on this package anymore. Do you maybe want to do it yourself and create a PR?

ibrod83 avatar Jul 13 '22 21:07 ibrod83

hey @LydiaF! Check out the latest version; I had wanted the same thing and submitted a PR to return all data types for getElementContent

jamin84 avatar Jan 02 '23 00:01 jamin84

Hey, I'm not really working on this package anymore. Do you maybe want to do it yourself and create a PR?

Hey, sorry I didn't reply to this, don't remember reading :)

LydiaF avatar Jan 04 '23 14:01 LydiaF

hey @LydiaF! Check out the latest version; I had wanted the same thing and submitted a PR to return all data types for getElementContent

Great stuff @jamin84, I will check out and get back to you in next few days!

LydiaF avatar Jan 04 '23 14:01 LydiaF

@jamin84 Sorry for slow response, but it's perfect, thank you v v much!

LydiaF avatar Mar 25 '23 12:03 LydiaF