What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To find a page’s declared social-sharing thumbnail, inspect its HTML for <meta property="og:image" content="...">. The URL in content is the Open Graph image address; if it is relative, resolve it against the page URL. This finds what the page declares, but it does not guarantee that a social platform will display that image: the image must be reachable, and the platform may be showing cached data.

What you are extracting

An Open Graph image is metadata that identifies an image to represent a web page when it is shared or otherwise read as a social-graph object. The Open Graph protocol’s required basic properties are og:title, og:type, og:image, and og:url. The image property is an image URL intended to represent the page. It is not the image file embedded in the article body, nor is it necessarily the same image a particular platform ultimately chooses to show.

For a page author, the declaration commonly looks like this in the document’s <head>:

<meta property="og:title" content="Example article">
<meta property="og:type" content="website">
<meta property="og:url" content="https://example.com/article">
<meta property="og:image" content="https://example.com/images/share.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Illustration for the article">

The structured image properties are optional metadata about the image: its secure URL, MIME type, width, height, and alternative text can also be declared. A page may include more than one og:image. When there are competing values, the first tag in document order has precedence according to the Open Graph Protocol repository. Begin with that one rather than assuming the last image is the intended thumbnail.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Extract the image URL manually

  1. Open the exact page URL. Make sure you are inspecting the canonical page or the URL that is actually being shared, including any path and query string that affect the response.
  2. View the source HTML. In a desktop browser, use the page’s View Source command, or fetch the page with an HTTP client. Search the source for og:image. The relevant value is the content attribute of a meta element whose property is og:image.
  3. Resolve a relative value. If the content value begins with a path such as /images/share.jpg or is otherwise relative, combine it with the document URL. For example, /images/share.jpg on https://example.com/article becomes https://example.com/images/share.jpg. Do not resolve it against your computer’s current directory.
  4. Request the image URL. Open the resulting URL or fetch it with an HTTP client. Follow redirects and check whether the final response is actually an image. A tag can contain a plausible-looking URL while the server responds with an error, a login page, or an access-denied response.
  5. Check additional image tags only if needed. If there are multiple values, start with the first. Look at adjacent structured fields such as og:image:width, og:image:height, og:image:type, and og:image:alt, then test a later image if the first is unavailable or unsuitable.

Extract it with Python

This small script fetches the page’s HTML, parses the first og:image tag, resolves relative URLs, and prints the result. Install its dependencies with python -m pip install requests beautifulsoup4, then save the code as extract_og_image.py.

from urllib.parse import urljoin
import requests
from bs4 import BeautifulSoup

page_url = "https://example.com/article"
response = requests.get(
    page_url,
    timeout=20,
    headers={"User-Agent": "Mozilla/5.0"},
)
response.raise_for_status()

soup = BeautifulSoup(response.text, "html.parser")
tag = soup.find("meta", attrs={"property": "og:image"})

if tag is None or not tag.get("content"):
    print("No og:image value found in the fetched HTML")
else:
    image_url = urljoin(page_url, tag["content"].strip())
    print(image_url)

Replace page_url with the target page. The script deliberately reports the first matching tag, following Open Graph’s document-order precedence. raise_for_status() stops on HTTP error responses instead of silently parsing an error page as if it were the intended document. The request timeout limits how long it waits for the page response; it does not guarantee that a site will allow automated requests.

This is a raw-HTML approach. If the page inserts its metadata only after JavaScript runs, a regular HTTP request may not see it. First compare the fetched HTML with the browser’s View Source output; if the tag is absent in both, the page may not declare it. If the browser’s rendered DOM contains it but the fetched source does not, use a browser-rendering approach or a service that renders pages, while recognizing that an Open Graph extraction tool and a screenshot tool solve different tasks.

Verify the URL and diagnose a wrong preview

Finding a tag is only the first check. A working preview depends on the image URL, the page response, and the platform’s own retrieval and cache behavior. Compare the HTML declaration with what the sharing platform reports rather than assuming the source tag alone explains the result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • No tag in the source: the page may omit og:image, or the metadata may be added only after JavaScript execution. Inspect the served HTML and rendered page separately.
  • The image URL is relative: resolve it against the page URL with a URL-joining function, not by concatenating strings. String concatenation can create malformed paths when the page URL already includes a directory or trailing slash.
  • The image request redirects or fails: follow the redirect chain and inspect the final response. Check for an unavailable file, access restrictions, or a response that is HTML rather than an image. A URL that opens for you may still be inaccessible to a platform’s crawler.
  • The preview shows an old image: a platform may have cached an earlier scrape. Its Sharing/Object Debugger can help compare the platform’s parsed result with the current page declaration and refresh or re-fetch data where the tool permits.
  • The page has several image declarations: inspect their order. The first og:image takes precedence in conflicts; do not assume an image farther down supersedes it.
  • The source is malformed or inconsistent: check that the tag is in the document head, the property name is spelled correctly, the content value is a valid URL, and the page’s og:url describes the intended object. A platform parser may not behave like a forgiving browser when markup is malformed.

Google Search Central also includes og:image in its image-markup examples and advises against generic images such as a site logo where a page-specific image is appropriate. A share image should represent the particular page, not merely fill the metadata field.

Choose an approach for one page or many

Approach Best for Important limitation
View Source and search Inspecting one page and understanding its exact declaration Manual; does not validate whether a platform can retrieve the image
HTTP client plus HTML parser Repeatable extraction in a script or service Reads the fetched HTML; may miss metadata added only by JavaScript
Platform Sharing/Object Debugger Investigating how Facebook interprets a page and whether its preview is stale Platform-specific; its displayed result is not a universal preview for every service
Metadata extraction API Processing many URLs without writing and maintaining your own parser Check the provider’s current limits, pricing, authentication, and availability
Rendered browser or screenshot Seeing the visual page as a browser renders it A screenshot shows pixels; by itself it does not identify the og:image metadata value

For bulk work, a parser in your own service offers control over redirects, request headers, retries, and how failures are recorded. A documented metadata API can reduce implementation work by returning Open Graph, Twitter Card, or HTML meta tags, but verify the provider’s current limits and commercial terms before building a workflow around it. For platform-specific preview validation, use that platform’s debugger rather than treating a generic metadata result as proof of what every service will show.

Or skip the browser setup

If the goal is to capture what a page looks like rather than extract its metadata, ScreenshotNeo is a website screenshot API and MCP server. It does not return the og:image field; use the HTML method above for that. Its screenshot can help inspect the rendered page visually. One GET request returns an image or PDF, and the options include full-page capture and a selected CSS element.

For example, save a screenshot of a target page with cURL:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/article -o shot.webp

See the ScreenshotNeo API documentation for request parameters. Cookie banners, popups, and chat widgets are removed before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common extraction errors and fixes

The script says no image was found

Check the exact response body the script fetched, not only what the browser displays after the page loads. Confirm the page URL redirects where expected, then search for both og:image and og:image:url. If metadata is added by client-side JavaScript, the raw HTTP response may not contain it; use a rendering-capable method or inspect the page’s server-generated metadata.

The printed URL is malformed

Use urljoin(page_url, content_value) to resolve relative URLs. Also inspect whitespace, HTML entity encoding, and whether the tag has a non-empty content attribute. Avoid manually adding a domain to a value that may already be absolute.

The URL opens the wrong content

Follow redirects and inspect the final response URL and content type. If the response requires authentication, blocks automated fetches, or serves an HTML error page, the URL is not publicly retrievable in the way the preview crawler may need.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The extracted image differs from the social preview

Check for multiple tags and their order, then compare the page source with the platform’s Sharing/Object Debugger result. If the current source is correct but the platform result is old, its cache may need a re-scrape. Changing the tag alone does not necessarily invalidate an already stored preview immediately.

The Python request times out or returns an HTTP error

Confirm the URL is reachable, increase the timeout only if the host is legitimately slow, and inspect the exception or status code before retrying. Repeated retries against a blocking or unavailable host will not fix the underlying access problem. For a production crawler, set explicit timeouts, handle redirects and HTTP errors, and record failures distinctly from pages that simply lack an image tag.

Practical checks before using the extracted image

  • Keep both the original metadata value and the resolved absolute URL if you need reproducible debugging.
  • Confirm the image endpoint returns an image, and record redirects or access errors rather than silently treating them as success.
  • When validating multiple candidates, preserve document order and associate structured fields with the relevant image tag.
  • For a wrong social card, compare three things separately: the page’s current HTML, the image URL’s actual response, and the platform debugger’s parsed or cached result.
  • For batch jobs, distinguish network failures, malformed pages, missing tags, and inaccessible images so each issue has an appropriate fix.

Frequently Asked Questions

Is og:image the same as a Twitter Card image?

Not necessarily. A page may declare separate Twitter Card metadata; inspect the relevant card tags as well as Open Graph when diagnosing a service-specific preview.

Does extracting og:image give me permission to reuse the image?

No. Metadata identifies a URL; it does not establish the image’s copyright status or grant permission to republish it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.