码迷,mamicode.com
首页 > 其他好文 > 详细

新浪模拟登陆

时间:2015-09-10 14:24:39      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
#-*-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
View Code

 

新浪模拟登陆

标签:

原文地址:http://www.cnblogs.com/chenyang920/p/4797713.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!