Reader small image

You're reading from  The Applied Data Science Workshop - Second Edition

Product typeBook
Published inJul 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781800202504
Edition2nd Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Alex Galea
Alex Galea
author image
Alex Galea

Alex Galea has been professionally practicing data analytics since graduating with a masters degree in physics from the University of Guelph, Canada. He developed a keen interest in Python while researching quantum gases as part of his graduate studies. Alex is currently doing web data analytics, where Python continues to play a key role in his work. He is a frequent blogger about data-centric projects that involve Python and Jupyter Notebooks.
Read more about Alex Galea

Right arrow

6. Web Scraping with Jupyter Notebooks

Activity 6.01: Web Scraping with Jupyter Notebook

Solution:

  1. Run the following code in your notebook to load the necessary libraries:
    import pandas as pd
    import numpy as np
    import datetime
    import time
    import os
     
    import matplotlib.pyplot as plt
    %matplotlib inline
    import seaborn as sns
    import requests
    from bs4 import BeautifulSoup
    %config InlineBackend.figure_format='retina'
    sns.set() # Revert to matplotlib defaults
    plt.rcParams['figure.figsize'] = (9, 6)
    plt.rcParams['axes.labelpad'] = 10
    sns.set_style("darkgrid")
     
    %load_ext watermark
    %watermark -d -v -m -p \
    requests,numpy,pandas,matplotlib,seaborn,sklearn
  2. After defining the url variable, load that page in the notebook using an IFrame. This can be done by running the following code:
    url = 'https://en.wikipedia.org/wiki/List_of_countries_and'\
          '_dependencies_by_population'
    from IPython...
lock icon
The rest of the page is locked
Previous PageNext Chapter
You have been reading a chapter from
The Applied Data Science Workshop - Second Edition
Published in: Jul 2020Publisher: PacktISBN-13: 9781800202504

Author (1)

author image
Alex Galea

Alex Galea has been professionally practicing data analytics since graduating with a masters degree in physics from the University of Guelph, Canada. He developed a keen interest in Python while researching quantum gases as part of his graduate studies. Alex is currently doing web data analytics, where Python continues to play a key role in his work. He is a frequent blogger about data-centric projects that involve Python and Jupyter Notebooks.
Read more about Alex Galea