- Apr 23, 2012
- 2,853
- 5,869
Hello lovelies,
Been a while since I dropped something. So am here again, sharing something with you all.
You've shown a lot of love to my Keyword Clustering Script, Keyword Similarity Check and
The Problem
How can we make use of the SERPs to enhance our Content? Enter Google Scraper + Summarizer
The Magic of the script
This script will
1. Scrape Google SERPs
2. Extract top 5 results (configurable)
3. Visit those website and extract the content
4. Summarize the content using GPT 3.5 Turbo
5. Save Summaries to a JSON file with the keyword name. (So the Summar for the keyword "Best SEO Forum" will be saved to "Best SEO Forum.json"
6. Removes all done keywords from keywords.csv
How to install
Using the Script
How the Script works?
Features of the Script
Hope some of you can find this useful
//
Mod Edit: Removed content that is not related to the subforum or topic.
Been a while since I dropped something. So am here again, sharing something with you all.
You've shown a lot of love to my Keyword Clustering Script, Keyword Similarity Check and
The Problem
How can we make use of the SERPs to enhance our Content? Enter Google Scraper + Summarizer
The Magic of the script
This script will
1. Scrape Google SERPs
2. Extract top 5 results (configurable)
3. Visit those website and extract the content
4. Summarize the content using GPT 3.5 Turbo
5. Save Summaries to a JSON file with the keyword name. (So the Summar for the keyword "Best SEO Forum" will be saved to "Best SEO Forum.json"
6. Removes all done keywords from keywords.csv
How to install
- Clone the Repository:
Code:git clone https://github.com/iamBlogPro/Scrape-Summarize.git cd Scrape-Summarize
Or Download the ZIP of the file
https://github.com/iamBlogPro/Scrape-Summarize/archive/refs/heads/main.zip
Extract and Open it in VS Code or an IDE of your choice.
- Install Required Packages:
Bash:pip install -r requirements.txt
- Download Chromedriver:
Download Chromedriver from here and place it in the same directory as the script.
Now the latest Chrome is super buggy. I recommend using Chome 110 and the chromedriver associated with it (Let me know if you want download links)
- Edit the settings.json:
Edit a settings.json file in the root directory with the following content:
JSON:{ "openai_api_key": "your_openai_api_key", "output_directory": "Output_Folder_Name", "keywords_file": "keywords.csv", "proxy_file": "proxylist.txt" }
Replace "your_openai_api_key" with your actual OpenAI API key
- In magic.py - add any domain you don't want scraped, or any extensions you don't want or any words in the URL you don't want
You can find this aroundline 142
Python:def get_links_with_beautifulsoup(driver): logging.info("Retrieving page source for URL extraction") skip_domains = ["reddit.com", "istockphoto.com", "groupon.com", "youtube.com", "tiktok.com", "facebook.com", "twitter.com", "petsmart.com", "linkedin.com"] skip_extensions = [".gov", ".in", ".uk"] skip_words = ["collections", "login", "signin", "advisor", "gov"]
Using the Script
- Prepare Input Files:
- Keywords File (
keywords.csv): A CSV file containing keywords to search for. Each keyword should be on a separate line without a header. - Proxy File (
proxylist.txt): A text file containing proxies in the format iport:username
assword, one per line.
- Keywords File (
- Run the Script:
Bash:python magic.py
How the Script works?
- Initialization:
- Loads settings from settings.json.
- Sets up logging to capture script execution details.
- Proxy Management:
- Loads proxies from
proxylist.txt.
- Loads proxies from
- Keyword Processing:
- Reads keywords from
keywords.csv. - For each keyword, it performs a Google search using
Selenium.
- Reads keywords from
- Content Extraction:
- Retrieves the page source and uses BeautifulSoup to extract URLs.
- Filters URLs based on predefined criteria (e.g., domain, extensions, keywords).
- Data Extraction and Summarization:
- Extracts content from each URL using
Trafilatura. - Cleans the extracted content.
- Summarizes the content using OpenAI's GPT-3.5 Turbo.
- Extracts content from each URL using
- Output:
- Saves the summarized content to JSON files in the specified output directory.
- Updates the
keywords.csvfile to remove processed keywords.
- Logging
The script generates log files in the logs directory, which can be used to monitor its execution and troubleshoot any issues.
Features of the Script
- Proxy Management - Automatically loads and manages a list of proxies to avoid IP bans and ensure continuous scraping.
- Headless Browser - Uses Selenium with headless Chrome for efficient and seamless web scraping.
- Content Extraction - Employs Trafilatura to extract and clean textual content from web pages.
- URL Filtering - Filters out irrelevant URLs based on predefined criteria to ensure only relevant content is processed.
- Summarization - Utilizes OpenAI's GPT-3.5 Turbo to generate concise summaries of extracted content.
- Logging - Provides detailed logging for monitoring script execution and debugging purposes.
- Configuration Management - Stores configurable parameters such as API keys, file paths, and directories in a JSON settings file for easy modification.
Hope some of you can find this useful
//
Mod Edit: Removed content that is not related to the subforum or topic.
Last edited by a moderator: