python 实现cm批量上传

import requests
import json
import time
import random

url = 'http://cm.admin.xxxx.com/customer/aj_addcontent.php'

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0',
'Referer':'http://cm.admin.weibo.com/customer/customerInfo.php?type=1&uid=5195970647',
'Cookie':'PHPSESSID=6a63d980ta1i11mg5sr6dbo4k6; BD-ADMIN-G0-TC=c566a5c61739c08a83ae255975d4545e; _SECRET=d8e6970e2c26193f8ffeffe38e2d84e3; _INFO=2903gVsIwYR8sHdGS%2BaHsAkusffES%2FUFEv6GQcxMYp%2FlduFyNy2CxTA2GAHpSw0Vn6Aw0ZH0yt2r78gWcgUfHY1eMr2t6LCFzwDg5x7zwL3yI97qVY84nJK7u6Q'}

content = [‘1’,'2','3']


with open('uids.txt','r') as f:
    for i in f:
        data = {
            'nickname':'',
            'uid':i.strip(),
            'company':'',
            'contents':'',
            'content':random.choice(content),
        }
        try:
            res = requests.post(url,data,headers=headers)
            a = json.loads(res.text)['msg']
            time.sleep(random.randint(2,6))
            print(a)
            if '添加成功' in a:
                print(a)
            else:
                print(a + i)
        except Exception as e:
            print(e,i)

 

posted @ 2017-08-18 17:56  Erick-LONG  阅读(301)  评论(0编辑  收藏  举报