-
Notifications
You must be signed in to change notification settings - Fork 127
ALwrity On Page SEO Analyzer AI Tool
The on_page_seo_analyzer.py
module is a comprehensive tool designed to analyze the on-page SEO of a website. It leverages various libraries such as requests
, streamlit
, bs4
, cloudscraper
, and more to fetch, parse, and analyze the content of a webpage to provide detailed SEO insights.
-
fetch_and_parse_html(url)
: Fetches HTML content from the given URL using CloudScraper and parses it with BeautifulSoup.
-
extract_meta_data(soup)
: Extracts metadata such as title, description, robots directives, viewport, charset, and language from the parsed HTML.
-
analyze_headings(soup)
: Analyzes the headings (H1 to H6) on the webpage.
-
check_readability(text)
: Checks the readability score of the text using thetextstat
library.
-
analyze_images(soup, url)
: Analyzes the images on the webpage, including their src and alt text.
-
analyze_links(soup)
: Identifies broken internal and external links on the webpage.
-
suggest_ctas(soup)
: Suggests call-to-action phrases present on the webpage.
-
extract_alternates_and_canonicals(soup)
: Extracts canonical URL, hreflangs, and mobile alternate links from the parsed HTML.
-
extract_schema_markup(soup)
: Extracts schema markup data from the parsed HTML.
-
extract_content_data(soup, url)
: Extracts content data such as text length, headers, and insights about images and links.
-
extract_open_graph(soup)
: Extracts Open Graph data from the parsed HTML.
-
extract_social_tags(soup)
: Extracts Twitter Card and Facebook Open Graph data from the parsed HTML.
-
check_page_speed(url)
: Fetches and analyzes page speed metrics using the Google PageSpeed Insights API.
-
check_mobile_usability(soup)
: Checks if the website is mobile-friendly based on viewport and other elements.
-
check_alt_text(soup)
: Checks if all images have alt text.
-
fetch_seo_data(url)
: Fetches SEO-related data from the provided URL and returns a dictionary with results.
-
download_csv(data, filename='seo_data.csv')
: Downloads the SEO data as a CSV file.
-
analyze_onpage_seo()
: Main function to analyze on-page SEO using Streamlit.
To use this module, you need to have the following Python packages installed:
requests
streamlit
beautifulsoup4
cloudscraper
pandas
plotly
tenacity
validators
readability
textstat
Pillow
You can install these packages using pip:
pip install requests streamlit beautifulsoup4 cloudscraper pandas plotly tenacity validators readability textstat Pillow
import streamlit as st
from on_page_seo_analyzer import analyze_onpage_seo
if __name__ == "__main__":
analyze_onpage_seo()
Fetches HTML content from the given URL using CloudScraper and parses it with BeautifulSoup.
Extracts meta data like title, description, and robots directives from the parsed HTML.
Analyzes the headings on the webpage.
Checks the readability score of the text.
Analyzes the images on the webpage, including their src and alt text.
Identifies broken internal and external links on the webpage.
Suggests call-to-action phrases present on the webpage.
Extracts canonical URL, hreflangs, and mobile alternate links from the parsed HTML.
Extracts schema markup data from the parsed HTML.
Extracts content data such as text length, headers, and insights about images and links.
Extracts Open Graph data from the parsed HTML.
Extracts Twitter Card and Facebook Open Graph data from the parsed HTML.
Fetches and analyzes page speed metrics using Google PageSpeed Insights API.
Checks if the website is mobile-friendly based on viewport and other elements.
Checks if all images have alt text.
Fetches SEO-related data from the provided URL and returns a dictionary with results.
Downloads the data as a CSV file.
Main function to analyze on-page SEO using Streamlit.
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please open an issue or submit a pull request to contribute to this project.