2020-09 Presentation

Scraping data from a webpage with Requests and BeautifulSoup

Presenter: Andrew P.

BeautifulSoup and Requests are powerful Python libraries that can be used in conjunction to web scrape or extract information from html pages. This can be extremely beneficial when trying to extract information for analyzation, working on a business project, or simply making life easier when parsing through information.

The first example covers extracting stock prices from Yahoo finance. Using the find() method, we are able to look for a specific tag and class on a html page and extract it with .text. This a good example of making a personal project to keep up with finances and such.

The second example showcases the benefits BeautifulSoup provides in data collection. In this example, we are collecting police data from killedbypolice.net to analyze the demographics and circumstances in which people are killed by police. Since we are looking for multiple data on a single page, we use a for loop to loop through each tag that contains data and enumerate to single out only the bits of information you need through index numbers. One can see how this can be used to business projects or research papers with this example.

Advertisement