SeleniumSEO is a Python package designed to help with SEO keyword extraction from web pages using Selenium and BeautifulSoup. It allows you to extract and analyze content from specified HTML tags (like paragraphs, headings, and lists), clean the data by removing stop words, and generate a keyword frequency report. This is particularly useful for SEO professionals and web scraping enthusiasts looking to analyze web pages for SEO optimization.
Extracts text from common HTML tags like <p>, <h1>, <h2>, <h3>, and <li>.
- Cleans the extracted text by removing common stop words.
- Removes non-alphabetical characters to focus on meaningful keywords.
- Provides a frequency count of keywords from a webpage.
- Easily configurable to specify custom tags and stop words.
You can install selenium-seo via pip. First, make sure you have Selenium and BeautifulSoup installed, as they are required dependencies:
pip install selenium beautifulsoup4Then, install selenium-seo:
pip install selenium-seoHere's a basic example of how to use the SeleniumSEO class to extract and analyze keywords from a webpage:
fromseleniumimportwebdriverfromselenium.webdriver.support.uiimportWebDriverWaitfromselenium_seoimportSeleniumSEO# Initialize WebDriver (Chrome in this case)driver=webdriver.Chrome()
# Specify the URL to scrapeurl="https://www.example.com"driver.get(url)
# Wait for the page to fully loadWebDriverWait(driver, 10).until(lambdadriver: driver.execute_script("return document.readyState") =="complete")
# Initialize the SeleniumSEO class with the driverseo=SeleniumSEO(driver)
# Get the cleaned keyword frequencieskeywords=seo.process_keywords()
# Print the keywords and their countsforword, countinkeywords:
print(f"{word}: {count}")
# Close the driver after scrapingdriver.quit()process_keywords()
Extracts keywords from the page and returns a sorted list of keywords with their frequency count.
set_tags(tags)
Sets the tags to be processed (default: ['p', 'h1', 'h2', 'h3', 'li']).
get_tags()
Returns the current tags being processed.
set_ignore_words(words)
Sets the list of stop words to ignore during keyword extraction.
get_ignore_words()
Returns the current list of stop words being ignored.
This project is licensed under the terms of the Apache License 2.0.
Selenium for browser automation. BeautifulSoup for HTML parsing.