Today I want to bring you a fun python Small cases ~
Don't talk much , Let's start ~
what are you having? python I won't answer the related error report 、 Or source code information / Module installation /
Women's clothing bosses are proficient in skillsYou can come here :(https://jq.qq.com/?_wv=1027&k=2Q3YTfym) perhaps +V:python10010 Ask me
Sign up for an account and log in
http://api.tianqiip.com/white/add?key=xxx&brand=2&sign=xxx&ip= Enter your computer's ip Address
1. win+R Input cmd
2. Enter enter in the pop-up window ipconfig
At present ipv4 Just your own ip Address
3. Add whitelist ( Input ip Then visit directly )
http://api.tianqiip.com/white/add?key=xxx&brand=2&sign=xxx&ip= Enter your computer's ip Address
remarks : Everyone's address is different, and you need to extract it yourself ip Page search
def sendEmail(title, content, received_mail):
# Mailbox property configuration
# Mailbox server
mailserver = 'smtp.qq.com'
# Sender - I wrote this email casually
userName_SendMail = '***@qq.com'
# Email authorization code - The authorization code generated according to step 4 for the sender's mailbox
userName_AuthCode = '******'
# Define the recipient of the message - I wrote it casually , If there are many recipients , A list can be used to represent
received_mail = [received_mail]
# Send a simple email , Process mail content
# content = content
# Definition of mail content in plain text , adopt MIMEText To operate ,plain It is the default display form of text
email = MIMEText(content, 'plain', 'utf-8')
email['Subject'] = title # Define email subject
email['From'] = userName_SendMail # Sender
email['To'] = ','.join(received_mail) # The recipient ( Multiple can be added , If there is only one recipient , You can write the email number directly )
# Send E-mail
# QQ The port number of the mailbox is 465, The port numbers of other mailboxes can be determined by themselves , Not QQ mailbox , In general use SMTP that will do , There is no need for SSL
smtp = smtplib.SMTP_SSL(mailserver, port=465)
smtp.login(userName_SendMail, userName_AuthCode)
smtp.sendmail(userName_SendMail, ','.join(received_mail), email.as_string())
smtp.quit()
print(' Mail sent successfully ')
First , Find out where the data you want is
Open developer tools , Click the magnifying glass , Search keywords
And then in Headers Find the data in url link
Import the required modules , And the written code
import requests
import re
from SendEmail import sendEmail
Get the news information you want
url = 'https://top.baidu.com/board?tab=realtime&sa=fyb_realtime_31065'
response = requests.get(url)
content = re.findall('<!--s-data:(.*?)-->', response.text)[0]
sendEmail(" Today, baidu Hot search ", content, '****@qq.com')