Introduction to Requests and Airfoils
Introduce the reader to airfoils and webscraping.
We'll cover the following
Airfoils
Airfoils are 2D cross-sections of wings, and they are primarily used to perform first-order modeling of lift and drag at different speeds and angles of attack. This image from RC modelers shows the anatomy of an airfoil:
Professor Michael Selig at the University of Indiana at Urbana-Champaign (UIUC) has posted an exhaustive list of airfoils and their coordinates at his UIUC website [1]. Airfoils can be designed to maximize or minimize different characteristics, so there are many different airfoil designs.
The Requests
library is one of many libraries used to make HTTP and HTTPS website requests. It allows you to interact with websites, submit forms, get texts from websites, and more. Though it is not a built-in library, it is one of the most popular libraries for web scraping. You will use Requests
to help get airfoil coordinates and plot them with Matplotlib
. You can find the Requests documentation link under footnote [2].
You will use Requests
to make an application programming interface (API) out of the UIUC airfoil website so that you can get any airfoil’s coordinates and plot them with Matplotlib
. Your program will interface with the UIUC website and give you the coordinates of the requested airfoil. The program should flow as follows:
- Scrape the UIUC website for the specific airfoil coordinates
- Grab the coordinates and split them appropriately so that you have a list of x coordinates and y coordinates
- Do any data cleaning that may be required (removing leading or trailing spaces, getting rid of any tabs, getting rid of any extra or unwanted characters, etc.)
- Plot the coordinates
This chapter, in particular, will develop the code as you read. A lot of programming resources go from talking about the program to having the entire program written in one step. There is a lot of troubleshooting and debugging that happens in between the two steps, and being able to debug well is a great skillset to have. See if you notice any problems before they appear, and see if you can think of a better way to write the program as you read.
Get hands-on with 1400+ tech skills courses.