May 2019
Beginner
528 pages
29h 51m
English
12.1 (Web Scraping with the Requests and Beautiful Soup Libraries) Web pages are excellent sources of text to use in NLP tasks. In the following IPython session, you’ll use the requests library to download the www.python.org home page’s content. This is called web scraping. You’ll then use the Beautiful Soup library37 to extract only the text from the page. Eliminate the stop words in the resulting text, then use the wordcloud module to create a word cloud based on the text.
In [1]: import requestsIn [2]: response = requests.get('https://www.python.org')In [3]: response.content # gives back the page's HTMLIn [4]: from bs4 import BeautifulSoupIn [5]: soup = BeautifulSoup(response.content, ...
Read now
Unlock full access