Read this article to understand the stock news push method based on python

For friends who can't keep an eye on the market, it would be great if there was a program that could notify you of the current progress of the stocks you are paying attention to. Of course, this is completely achieved by writing a monitoring notification program. When the market situation meets your own monitoring strategy, you will send a message to notify yourself in time, so you don't have to worry about missing the market situation.

The main ways to receive push messages are as follows:

  • Notification via email: It needs to be configured separately, and the timeliness is generally not good. It is suitable for a large amount of monitoring information.

  • SMS notification: The SMS API goes through the mobile gateway and generally requires a fee.

  • Notification via chrome browser plug-in: Requires development & installation of separate browser plug-in

  • Notifications via WeChat, DingTalk, etc.: WeChat and corporate WeChat message notifications are connected

Through comparison, it can be seen that sending notifications through WeChat should be the best choice for individuals. There are two specific implementation methods:

  • Push notifications via Enterprise WeChat

  • Push notifications via third-party tool websites

Push notifications via Enterprise WeChat

This method does not require the installation of the enterprise WeChat client. You can receive messages directly in WeChat and display the full text. However, the following steps are required:

  • Need to register for Enterprise WeChat

  • An alarm application needs to be created in Enterprise WeChat

  • Applications created after June 20, 2022 need to configure additional trusted IPs

  • Call the enterprise WeChat API

The advantage of this method is that the message capacity that can be pushed every day is relatively large, there are many configurable options, and it has advanced functions such as sending pictures, cards, files or Markdown messages. The disadvantage is that the overall process is slightly complicated, and it needs to be bound to a fixed public network IP to push notifications. The local development machine will report an error when pushing messages. If you are interested, I will find an opportunity to write a separate article to explain later.

Push notifications via third-party tool websites

The process of applying for corporate WeChat is relatively long, and problems are likely to arise in the process, which is difficult to solve without experience. If there are not that many messages to be pushed every day, you can use third-party tool websites to complete the message push, such as wxpusher, Pushplus, server rice, and server sauce. The limitations of these tools are explained below:

  • pushplus: Free accounts are limited to 200 requests per day, and can receive up to 5 requests in 1 minute. Exceeding requests will not be pushed. For the same content, there is a limit of 3 messages sent within 1 hour.

  • Server rice : A single account is limited to 100 requests per day.

  • wxpusher: A single WeChat user can receive up to 500 messages a day

  • Server Sauce: The new free account can receive up to 5 messages a day

Since these tools are all implemented based on the WeChat official account, and the WeChat official account has a daily upper limit for template message push, template messages will not be sent on the day exceeding this upper limit, which means that users of this tool will not be able to use the push function of the WeChat channel.

The push code is relatively simple to implement in Python. The following uses pushplus as an example. The sample code is as follows:

import requests

def send_wechat_msg(title, content):
    token = 'xxx'
    url = 'http://www.pushplus.plus/send?token=' + token
    url = url +'&title=' + title + '&content=' + content
    requests.get(url) 

Just call the send_wechat_msg() function where needed

Summary & communication

Follow the public account: Zhuge Shuo Talk to get more related content.

Writing articles is not easy. If you think this article is helpful to you, please give it a thumbs up and forward it to give me the motivation to keep writing good articles.

Guess you like

Origin blog.csdn.net/richardzhutalk/article/details/131387578