How to message the girl you like in Python

Everyone should learn to program now, after all programs can play a big role in our later life.

Some things are repetitive, and doing them every day may not feel interesting, after all, we are all lazy. But there are things that have to be done, like now you're talking to a certain girl, ready to go further.

You can send some fixed content such as good morning and evening, news push and so on at regular times every day. You don't necessarily have to think or do it on time, but these things can be done programmatically.

Below I will share how to use Python to help you catch someone you like.

What we need to prepare is:

          A computer with Python installed

          We chat number

After copying the code, you only need to modify the remarks in the code to send timed messages to the girls you like. You can also modify the content to be sent by yourself. The code is best hung on the server, I wish you to find the person you love as soon as possible.

code show as below:

# -*- coding:utf-8 -*- 
from __future__ import unicode_literals
import itchat
import urllib2
import json
from threading import Timer


def get_news():
# Get Kingsoft Daily Sentence (English, translation, hot comment)
url = "http ://open.iciba.com/dsapi"
headers = {"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) CriOS/66.0 .3359.122 Mobile/15E216 Safari/604.1"}

req = urllib2.Request(url, headers=headers)
res = urllib2.urlopen(req)
r = res.read()
#print r
# Parse the obtained string
r = r.decode('unicode_escape')
b = json.loads(r)
contents = b['content']
translation = b['translation']
note = b['note']
return contents, note, translation

def send_news():
try: #Login

to your WeChat account, a web page QR code will pop up, scan it to log in to
itchat.auto_login (hotReload = True)
# Get the remarks of your corresponding friend, this small face remark is an example of
mine my_friend = itchat.search_friends(name=u'Ma Baopo')
# Get a string of numbers corresponding to the remark name
MaBaopo = my_friend[ 0]["UserName"]
message1 = get_news()[0]
#Translation
message2 = get_news()[1]
message3 = get_news()[2][5:] #Send

message
itchat.send(message1, toUserName = MaBaopo)
itchat.send(message2, toUserName = MaBaopo)
itchat.send(message3, toUserName = MaBaopo)
# Send it once a day (t=86400 seconds), just hang it all the time
t = Timer(86400, send_news)
t.start()
except:
message4 = u"favorite Your person appeared today /bug /(ㄒoㄒ)/~~"
itchat.send(message4, toUserName = MaBaopo)

def main():
send_news()

if __name__ == "__main__":
main()



          

          

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325303688&siteId=291194637