ibrod83 / nodejs-web-scraper

81 stars 26 forks source link

Transform via getElementContent #29

Closed LydiaF closed 1 year ago

LydiaF commented 2 years ago

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

ibrod83 commented 2 years ago

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

jamin84 commented 1 year ago

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

LydiaF commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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