微博群发私信

 1 import requests
 2 import json
 3 import time
 4 url = 'http://weibo.com/aj/message/add?ajwvr=6'
 5 headers = {
 6     'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.22 Safari/537.36 SE 2.X MetaSr 1.0',
 7 'Referer':'http://weibo.com/message/history?uid=2186989853&name=ROY_zhc',
 8     'Cookie':'SINAGLOBAL=5450357842753.007.1478158728462; __gads=ID=dc8a0460ce5af255:T=1489578899:S=ALNI_MYrN6m9721fFYGIaxBwegZ9ByUO1g; wvr=6; TC-V5-G0=7975b0b5ccf92b43930889e90d938495; SCF=ApzT2KV9xmTEjJUK4YRFlJExEX9fmOOwdl9nhqIuUVD_OhWU87Hd4w0sm_KUG1jz9vx5C428gy733JfN4JEf0c4.; SUB=_2A251231eDeRhGeNG7lsX8CnOyziIHXVWkemWrDV8PUNbmtAKLUTdkW8ouHLwUbmX2qOzUi0mLFzBKNnKVw..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9Wh_9o.MhDTX6AFesEjyWUKb5JpX5KMhUgL.Fo-RSK.cehMEehB2dJLoIEBLxKBLB.qLB.2LxK-LBo5L12qLxK-LBKqLB--LxK-L1hBLB.qt; SUHB=0z1ATn2tTI1217; ALF=1522548878; SSOLoginState=1491012878; _s_tentry=login.sina.com.cn; Apache=2395084912998.7793.1491012947796; ULV=1491012948399:136:1:9:2395084912998.7793.1491012947796:1490950378226; UOR=,,login.sina.com.cn; TC-Page-G0=07e0932d682fda4e14f38fbcb20fac81; TC-Ugrow-G0=370f21725a3b0b57d0baaf8dd6f16a18'
 9 }
10 13     for i in f:
14         data = {
15         'location':'msgdialog',
16         'module':'msgissue',
17         'style_id':'1',
18         'text':'''私信内容
19         ''',
20         'uid':i.strip(),
21         'tovfids':'',
22         'fids':'',
23         'el':'[object HTMLDivElement]',
24         '_t:0':'0'
25         }
26         try:
27             res = requests.post(url,data,headers=headers)
28             a = json.loads(res.text)['msg']
29             if '恭喜' in a:
30                 print(a)
31             else:
32                 print(a + i)
33         except Exception as e:
34             print(e,i)

 

import requests
import json
import time
url = 'https://m.weibo.cn/msgDeal/sendMsg?'

headers = {
'User-Agent':'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Mobile Safari/537.36','Cookie':'h5_deviceID=318a38391533b96b5e211f15bb109557; _T_WM=10f6881b13fd68fbcb3a458488e39054; ALF=1506591056; SCF=AjVnYn5w5MVRKBChxLVFcVRWP9YlRAZbNSb6l1VItKaZPbPmM8hXn5b7FrZw5z8Lf3B1g3Lc1TpPD-T5K5kuPwk.; SUB=_2A250oUQBDeRhGeVM6lIU8izEwjyIHXVUamxJrDV6PUJbktANLWLBkW2FvlLLJYotPvkFSGUkDvw1ujdEIg..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WhQMFyM94ynlSl9JBZenkS15JpX5o2p5NHD95Q0eo27SKzE1h.7Ws4DqcjZxPiDqcj_K2v1x7tt; SUHB=0rr7vHua1adtw0; SSOLoginState=1503999057; H5_INDEX=1; H5_INDEX_TITLE=Erick-LONG; M_WEIBOCN_PARAMS=featurecode%3D20000320%26luicode%3D20000174%26lfid%3Dhotword',
'Referer':'https://m.weibo.cn/msg/chat?uid=6019902350',
}

with open('biangxx.txt','r') as f:
    falied = []
    for i in f:
        data = {
        'fileId':'null',
        'uid':i.strip(),
        'content':'''xx''',
        'st':'10578d'
        }
        try:
            res = requests.post(url,data,headers=headers)
            a = json.loads(res.text)['msg']
            if '成功' in a:
                print(a)
            else:
                falied.append(i)
        except Exception as e:
            print(e)
            falied.append(i)
    print(falied)

 

posted @ 2017-04-19 13:52  Erick-LONG  阅读(2413)  评论(0编辑  收藏  举报