Word cloud of Google Search Results using Python

Generate word cloud from top results for a Google search query

Photo by Thimo Pedersen on Unsplash

Creating Word-cloud from top results of a Google Search Query

Flowchart of the full implementation

Key Python Functions

import google
from googlesearch import search
search
(query="Machine Learning", tld='com', lang='en', num=10, start=0, stop=10, pause=2.0)
Top 10 urls for the search query — ‘Machine Learning’
import urllib.request as url
url_link = "https://expertsystem.com/machine-learning-definition/"
url_content = url.urlopen(url_link).read()
HTML version of the url content
from bs4 import BeautifulSoup
text_content = BeautifulSoup(url_content, "lxml").text
Text content extracted by ‘lxml’ parser
from wordcloud import WordCloud
WordCloud
(max_font_size=100, max_words=100, background_color="white", random_state=0).generate(text_content)
Word Cloud for ‘Machine Learning’ from top search results

Full Implementation

Word Cloud for Kung Fu Panda

Improving the results

Data Science Professional | 6+ years of experience in analytics across various domains — retail, insurance, finance and digital advertising

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store