python socket send,python 即时通讯_用python实现发送即时消息到twitter

 2023-09-23 阅读 19 评论 0

摘要:1.[代码][Python]代码Python语言: 用python实现发送即时消息到twitter#!/usr/bin/env python#coding=utf-8python socket send。# 通过urllib2模块实现发送即时消息到Twitter.comimport re,urllib2,urllibuser = {'session[username_or_email]':'username

1.[代码][Python]代码

Python语言: 用python实现发送即时消息到twitter

#!/usr/bin/env python

#coding=utf-8

python socket send。# 通过urllib2模块实现发送即时消息到Twitter.com

import re,urllib2,urllib

user = {'session[username_or_email]':'username_or_email','session[password]':'******'}

data = {

'status':"""

python自动发送qq消息?Send by Python!

""",

'tab':'home',

'source':'web',

}

python自动发短信、def u(s, encoding):

if isinstance(s, unicode):

return s

else:

try:

python 推送消息到手机?return unicode(s, encoding)

except:

return s

def send(user=user,data=data):

c = urllib2.HTTPCookieProcessor()

python自动发送邮件。builder = urllib2.build_opener(c)

url = 'https://twitter.com/sessions'

request = urllib2.Request(

url=url,

data = urllib.urlencode(user)

python发送post请求?)

d = builder.open(request)

r = re.compile('')

x = d.read()

if len(re.compile(r"name=\"session\[username_or_email\]\"").findall(x))>0:

print "Login Error!"

return False

auth = {'authenticity_token':r.findall(x)[0]}

send = '%s&%s'%(

urllib.urlencode(auth),

urllib.urlencode(data)

)

request = urllib2.Request(

url='http://twitter.com/status/update',

data = send ,

)

builder.open(request)

return True

if __name__=="__main__":

import sys

if len(sys.argv)>1 and sys.argv[1]!="":

data["status"] = u(" ".join(sys.argv[1:]),"gb2312").encode("utf-8")

if send():

print 'ok'

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/91583.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息