官术网_书友最值得收藏!

Implementing the Weather Application

The first application in this book is going to be a web scraping application that will scrape weather forecast information from https://weather.com and present it in a terminal. We will add some options that can be passed as arguments to the application, such as:

  • The temperature unit (Celsius or Fahrenheit)
  • The area where you can get the weather forecast
  • Output options where the user of our application can choose between the current forecast, a five-day forecast, a ten-day forecast, and the weekend
  • Ways to complement the output with extra information such as wind and humidity

Apart from the aforementioned arguments, this application will be designed to be extendable, which means that we can create parsers for different websites to get a weather forecast, and these parsers will be available as argument options.

In this chapter, you will learn how to:

  • Use object-oriented programming concepts in Python applications
  • Scrape data from websites using the BeautifulSoup package
  • Receive command line arguments
  • Utilize the inspect module
  • Load Python modules dynamically
  • Use Python comprehensions
  • Use Selenium to request a webpage and inspect its DOM elements

Before we get started, it is important to say that when developing web scraping applications, you should keep in mind that these types of applications are susceptible to changes. If the developers of the site that you are getting data from change a CSS class name, or the structure of the HTML DOM, the application will stop working. Also, if the URL of the site we are getting the data from changes, the application will not be able to send requests. 

主站蜘蛛池模板: 依安县| 秦安县| 浦北县| 江安县| 丽江市| 乌鲁木齐县| 台东市| 水城县| 潮州市| 彭泽县| 延边| 元朗区| 东源县| 子洲县| 荆门市| 屏东县| 逊克县| 晋宁县| 忻州市| 陕西省| 沭阳县| 佛冈县| 新和县| 东源县| 墨竹工卡县| 偃师市| 陇西县| 黑河市| 长春市| 鄂州市| 保靖县| 潞西市| 印江| 依安县| 鸡泽县| 保亭| 将乐县| 建宁县| 红安县| 来凤县| 衡东县|