Searches Google's Programmable Search Engine for your query, visits each result's landing page, scrapes the readable text and saves it all to an output folder.
A command-line tool which authenticates against Google's Programmable Search Engine using your API key and search-engine ID. The application then runs each query you provide requesting as many result pages as you specify. The collected result links are normalized and de-duplicated so the same URL is never fetched twice.
From there, a number of concurrent workers visits each landing page, confirming the response is HTML before reading it and parses the markup with BeautifulSoup to extract the page title, meta description and the main readable body text. Pages which are blocked by domain, return errors, aren't HTML or yield no text are recorded as skipped. Everything is written to a single output folder.
Below are the required software programs and instructions for installing and using this application on a Linux machine.
-
Install the above programs
-
Open a terminal
-
Clone this repository:
git clone git@github.com:devbret/web-content-finder.git -
Navigate to the repo's directory:
cd web-content-finder -
Create a virtual environment:
python3 -m venv venv -
Activate your virtual environment:
source venv/bin/activate -
Install the needed dependencies:
pip install -r requirements.txt -
Create your configuration file from the template:
cp .env.template .env -
Open
.envand set values forAPI_KEY,CXand so on -
Run the program:
python3 app.py -
Downloaded content will be saved to the
outputdirectory -
When finished, exit the virtual environment:
deactivate
This project repo is intended to demonstrate an ability to do the following:
-
Query Google's Programmable Search Engine for one or more search terms and scrape the readable text from every result's landing page
-
Normalize result URLs by stripping tracking parameters and rely on a pool of concurrent workers to fetch each page
-
Use
BeautifulSoupto extract the page title, meta description and main body text, saving each page as an individual.txtfile -
Record each result's search rank, HTTP status, content hash, word count and skip reason
If you have any questions or would like to collaborate, please reach out either on GitHub or via my website.