标签:
#-*-coding:utf-8-*- import urllib2 import urllib import cookielib headers = {‘User-Agent‘:‘Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0‘} cookie = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) #login weibo login_url=‘http://login.weibo.cn/login/?backURL=&backTitle=&vt=4&revalid=2&ns=1‘ login_data=urllib.urlencode( { ‘mobile‘:‘***********‘, ‘password_****‘:‘*******‘, ‘remember‘:‘on‘, ‘backURL‘:‘http%253A%252F%252Fweibo.cn%252F‘, ‘backTitle‘:‘%E5%BE%AE%E5%8D%9A‘, ‘tryCount‘:‘‘, ‘vk‘:‘************‘, ‘submit‘:‘%E7%99%BB%E5%BD%95‘ } ) login_req=urllib2.Request( url=login_url, data=login_data, headers=headers ) login_res=opener.open(login_req) #/f1 = open(‘my_data.txt‘,‘w‘) #/f1.write(login_res.read()) #send message message_url = ‘http://weibo.cn/mblog/sendmblog?vt=4&st=438230‘ message_data = urllib.urlencode( { ‘rl‘:‘0‘, ‘content‘:‘DBDBD‘ } ) send_req = urllib2.Request(url = message_url,data = message_data,headers = headers) opener.open(send_req) #send
标签:
原文地址:http://www.cnblogs.com/chenyang920/p/4797713.html