You want to scrape craigslist for the latest rental price for a house, and you don't want to check the web page for it constantly. In a few code lines, you can pull the price from the website and have it in front of you. Let’s get started.
First, import the necessary libraries.
Next, we’ll set up our web scraping process. The page we are requesting is the URL from craigslist.
After looking through the text, we find our span and class. We can then use the find_all function to find span and desired class.
We want the latest price (most recent), so we call on the first price listed. Remember python’s first item in any list is represented with a 0.
We retrieve a price of $1,149.
Now in one cell, we see the whole process.
Craigslist is always updating, so from the time I ran the price.text to running the defined function above, a new post was made, thus changing the value.