Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The emitter opengraph produces rigid, fragile structures #153

Open
boxabirds opened this issue Sep 8, 2020 · 4 comments
Open

The emitter opengraph produces rigid, fragile structures #153

boxabirds opened this issue Sep 8, 2020 · 4 comments

Comments

@boxabirds
Copy link

Consider this HTML construct:

<meta property="og:title" content="‘A Path That Is Not Sustainable’: College Hits Breaking Point, Sends Home Majority of Student Body" />

This is turned into the following by the opengraph module:

       [
          "og:title",
          "‘A Path That Is Not Sustainable’: College Hits Breaking Point, Sends Home Majority of Student Body"
        ],

Does anyone know why this couldn't instead be:

"og:title":"‘A Path That Is Not Sustainable’: College Hits Breaking Point, Sends Home Majority of Student Body",

A case for having the output be this way:

  1. You can then do semantic selectors instead of positional selectors (["og:title"] vs [1])
  2. If there are multiple occurrences with an og:tag then I think this is a bug, certainly for the purposes of extruct. Or maybe I'm wrong on this.

Thoughts most welcome.

@lopuhin
Copy link
Member

lopuhin commented Sep 9, 2020

@boxabirds that's a good question. The output with uniform=True is already a dict like you describe: https://github.com/scrapinghub/extruct#uniform - so my understanding is that by default we do minimal post-processing, but also provide the data in a more convenient format.

@boxabirds
Copy link
Author

boxabirds commented Sep 9, 2020 via email

@boxabirds
Copy link
Author

So maybe we could update the docs so it emphasises that the uniform=True flag should be used in most new cases. I'd encourage the default to be this but that'd likely break your current users.

@sknebel
Copy link

sknebel commented Aug 2, 2021

If there are multiple occurrences with an og:tag then I think this is a bug, certainly for the purposes of extruct. Or maybe I'm wrong on this.

OpenGraph has arrays and elements where order between tags matters: https://ogp.me/#array Is this covered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants