Skip to content

ALwrity Open Graph Generator AI Tool

ي edited this page Jan 18, 2025 · 1 revision

AI Open Graph Tag Generator

Overview

The opengraph_generator.py module is designed to generate Open Graph (OG) tags, which are essential for optimizing how web pages are displayed when shared on social media platforms like Facebook and Twitter. This module leverages a text generation model to create these tags based on input hints and the content of the specified webpage.

Features

  • Generate Open Graph Tags: Automatically generate OG tags for any given URL.
  • Platform Specific Tags: Customize tags for general use, Facebook, or Twitter.
  • Extract Default OG Tags: Extract existing OG tags from a webpage.
  • Streamlit Integration: Provides a user-friendly interface for generating and displaying OG tags.

Use Cases

Social Media Optimization

Ensure that your web pages display optimally when shared on social media platforms by generating accurate and relevant OG tags.

SEO Enhancement

Improve your site's search engine ranking and click-through rates by providing detailed and accurate metadata.

Content Management

Easily manage and update OG tags for your webpage content, ensuring consistency and accuracy across all pages.

Installation

To use this module, you need the following Python packages installed:

  • streamlit
  • requests
  • beautifulsoup4
  • cloudscraper

Install the required packages using pip:

pip install streamlit requests beautifulsoup4 cloudscraper

Usage

Streamlit App

This module is designed to be run as a Streamlit application. Below is an example code snippet to run the Open Graph Tag Generator using Streamlit:

import streamlit as st
from opengraph_generator import og_tag_generator

if __name__ == "__main__":
    og_tag_generator()

Function Descriptions

generate_og_tags(url, title_hint, description_hint, platform="General")

Generates Open Graph tags based on the provided URL, title hint, description hint, and platform.

Parameters:

  • url (str): The URL of the webpage.
  • title_hint (str): A hint for the title.
  • description_hint (str): A hint for the description.
  • platform (str): The platform for which to generate the tags (General, Facebook, or Twitter).

Returns:

  • str: The generated Open Graph tags or an error message.

extract_default_og_tags(url)

Extracts default Open Graph tags from the provided URL.

Parameters:

  • url (str): The URL of the webpage.

Returns:

  • tuple: A tuple containing the title, description, and image URL, or None in case of an error.

og_tag_generator()

Main function to run the Streamlit app.

Example

Here is an example of how to use the Streamlit app to generate Open Graph tags:

  1. Run the Streamlit app:

    streamlit run opengraph_generator.py
  2. Open the Streamlit app in your browser.

  3. Enter the URL of the webpage you want to generate Open Graph tags for.

  4. Modify the existing title, description, and image URL or suggest new ones.

  5. Select the platform (General, Facebook, Twitter).

  6. Click "Generate Open Graph Tags" to generate the tags.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request to contribute to this project.