Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:28:21+00:00 2026-06-14T22:28:21+00:00

I have a site for shopping recommendations, which allows users to post the urls

  • 0

I have a site for shopping recommendations, which allows users to post the urls for items they recommend.

The form currently includes just a single input for a url to the main product page.

If a user were to post a link like below:

http://www.homedepot.com/webapp/wcs/stores/servlet/ProductDisplay?productId=203533553&storeId=10051&langId=-1&catalogId=10053&cm_sp=BlackFriday-_-11_23-_-Hero_C-_-349_Each_GE_Washer_Dryer_Special_Buy#.UK-DHuOe_VQ

I would want to show an image tag of the og:image included in this url.

Using the facebook open graph protocol page, I see that the example url above does indeed have an og:image

http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.homedepot.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProductDisplay%3FproductId%3D203533553%26storeId%3D10051%26langId%3D-1%26catalogId%3D10053%26cm_sp%3DBlackFriday-_-11_23-_-Hero_C-_-349_Each_GE_Washer_Dryer_Special_Buy%23.UK-DHuOe_VQ

How do I go about extracting the url to the og:image?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:28:22+00:00Added an answer on June 14, 2026 at 10:28 pm

    I ended up using Nokogiri like below, while relying heavy on this tutorial by Railscasts.

    def photo_from_url(url)
      if !Nokogiri::HTML(open(url)).css("meta[property='og:image']").blank?
        photo_url = Nokogiri::HTML(open(url)).css("meta[property='og:image']").first.attributes["content"]
        self.photo = URI.parse(photo_url)
        self.save
      end
    end
    

    I found this to be more reliable than the opengraph gem:

    url_with_photo = opengraph.fetch(url)
    url_with_photo.image
    

    as this second method sometimes doesn’t work, even on pages that have an og:image tag in the source code. (I didn’t implement it completely wrong, as it did work on some pages…).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed a shopping cart that allows both login and non-login users to
I have a lightweight online shopping site based on JSP and XML, and I'm
I have site which uses $(selector).load(path) function in more than 300 pages. Now my
I have a site that allows download or streaming of mp3 files. All the
I have a shopping site that works a little bit differently than the rest:
Currently I have a site that is using Google Checkout's mini cart system and
I have created a shopping cart site, and i have got two complains for
Suppose you have a shopping site that sells widgets. However, the inventory of each
I'm currently working with an e-commerce shopping site. It's quite unnecessary to describe that
I'm currently working with an e-commerce shopping site where different products require to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.