GithubHelp home page GithubHelp logo

Comments (5)

lopuhin avatar lopuhin commented on May 18, 2024 1

Hi, I'd like to work on this issue, can you assign it to me ?

Hi @ragnerok contributions are very welcome, I don't think anyone is working on this.

One way to solve this issue while keeping it backward compatible is to add a flag with_og_array that returns an og_array if it is true.

Sounds good to me šŸ‘

from extruct.

ivanprado avatar ivanprado commented on May 18, 2024

Same problem in my case. Open Graph with uniform avoids the possibility of extracting multiple images. Only last image is returned. Example:

import pprint
import extruct
pp = pprint.PrettyPrinter(indent=2)

html = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xmlns:og="https://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
 <head>
  <title>Himanshu's Open Graph Protocol</title>
  <meta http-equiv="Content-Type" content="text/html;charset=WINDOWS-1252" />
  <meta http-equiv="Content-Language" content="en-us" />
  <link rel="stylesheet" type="text/css" href="event-education.css" />
  <meta name="verify-v1" content="so4y/3aLT7/7bUUB9f6iVXN0tv8upRwaccek7JKB1gs=" >
  <meta property="og:title" content="Himanshu's Open Graph Protocol"/>
  <meta property="og:type" content="article"/>
  <meta property="og:url" content="https://www.eventeducation.com/test.php"/>
  <meta property="og:image" content="https://www.eventeducation.com/images/1.jpg"/>
  <meta property="og:image:width" content="400" />
  <meta property="og:image" content="https://www.eventeducation.com/images/2.jpg"/>
  <meta property="og:image:width" content="500" />
  <meta property="fb:admins" content="himanshu160"/>
  <meta property="og:site_name" content="Event Education"/>
  <meta property="og:description" content="Event Education provides free courses on event planning and management to event professionals worldwide."/>
 </head>
 <body>
 </body>
</html>"""

pp.pprint(extruct.extract(html, uniform=True)['opengraph'])

result:

[ { '@context': {'og': 'http://ogp.me/ns#'},
    '@type': 'article',
    'og:description': 'Event Education provides free courses on event planning '
                      'and management to event professionals worldwide.',
    'og:image': 'https://www.eventeducation.com/images/2.jpg',
    'og:image:width': '500',
    'og:site_name': 'Event Education',
    'og:title': "Himanshu's Open Graph Protocol",
    'og:url': 'https://www.eventeducation.com/test.php'}]

from extruct.

Gallaecio avatar Gallaecio commented on May 18, 2024

If backward compatibility is to be kept, Iā€™m not sure what the best approach would be.

from extruct.

osaid-r avatar osaid-r commented on May 18, 2024

Hi, I'd like to work on this issue, can you assign it to me ?

One way to solve this issue while keeping it backward compatible is to add a flag with_og_array that returns an og_array if it is true.

from extruct.

osaid-r avatar osaid-r commented on May 18, 2024

Hey @lopuhin, I've added the changes that I think will fix the issue. Could you look into it and let me know if I need to change something else ? I'll add the test cases in some time.

from extruct.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.