In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to use Python web crawler technology to automatically send weather forecast email, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
For weather information, the target website we collected is Sohu Weather Network, which is shown in the following figure:
Sohu Weather Network
The collection method still uses the BeautifulSoup selector to define the get_weather function, as shown in the following figure:
Define get_weather function
The collected information includes: current city, weather condition, current temperature, lowest temperature, highest temperature, air quality and PM2.5 value. Knowledge points such as string attributes, string formatting, and lambda functions are used in the code block. When using BS4 to match target information, it is recommended that you gradually conduct code testing and form a good habit, so that you will not be confused by code errors after writing.
After collecting the weather information, the next step is to write code to realize the automatic sending of mail. Define the send_email function, as shown in the following figure:
Define send_email function
After confirming the mailbox of the other party (or customer base), put it in the list, waiting to be traversed, and then you only need to enter your mailbox name, login password and mailbox server to send the information automatically. In this example, the editor takes his Sohu mailbox as an example, and the target city chooses Dalian, the city where the editor is located. After running the program, you will get the following effect picture:
Effect picture
Then log in to your Sohu mailbox, and then you can see that a weather forecast email is already in your unread email. Open the email message, as shown in the following figure:
Sohu mailbox inbox
It is obvious that the content of the email is exactly the same as the information collected. In this way, one-click sending and receiving of mail can be realized.
So is it only Sohu mailbox that can send mail? Of course not. 163The NetEase mailbox is fine. You only need to change the mailbox server. The effect is as follows:
Send a message to NetEase 163mailbox
Click on the email to view the contents of the email, as shown below:
NetEase 163mailbox inbox
Like Sohu's mailbox, the content of the email received and the information collected are exactly the same.
Finally, Amway takes a look at the mailbox server and PM2.5 standards of my friends.
1. Summary of some commonly used mailbox servers:
Tencent QQ Mail sending server: smtp.qq.com
NetEase 126mailbox sending server: smtp.126.com
NetEase 163mailbox sending server: smtp.163.com
Sina free mailbox sending server: smtp.sina.com.cn
Sohu mailbox sending server: smtp.sohu.com
Yahoo mailbox sending server: smtp.mail.yahoo.com
Gmail mailbox sending server: smtp.gmail.com
Second, the reference value of PM2.5
Air quality level 24-hour PM2.5 average standard value
You 35 micrograms (ug) per cubic meter
Good 35 μ g / cubic meter 75 μ g (ug)
Mild pollution 750.115 micrograms (ug) per cubic meter
Moderate pollution 115,150 micrograms (ug) per cubic meter
Heavy pollution 150,250 micrograms (ug) per cubic meter
Serious pollution 250 micrograms (ug) per cubic meter or more
From the collection results, the weather PM2.5 of Dalian is 110ug, which belongs to the range of mild pollution.
After reading the above, do you have any further understanding of how to use Python web crawler technology to automatically send weather forecast email? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.