python request

作者在 2016-11-06 15:57:33 发布以下内容
python request

公司 | 2016-10-12 15:31:41 | 63540次阅读 | 0评
#-*- coding:UTF-8 -*-  #
import sys, unittest, xmlrpclib, time, socket, select, multiprocessing , random,sqlite3,re,unicodedata,requests,time,json
from main import database
import esl_init
from main import create_task_data
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
import os
from xml.dom import minidom
from Cookie import Cookie
from web.webapi import cookies

# from PublicFunction import ReadXml
#esl = esl_init.ESL()

# server = xmlrpclib.ServerProxy('http://127.0.0.1:9000')

eslid = open("D:\\eslid.txt").readlines()
goodsid = open("D:\\goodsid.txt").readlines()

class BindOpera():
    def __init__(self):
        global cookies
        logindata = {
                "username": "chengtao",
                "password": "000000"
                    }
        s = requests.post("http://192.168.2.127:8080/shopweb/login",logindata)
        cookies = s.cookies
        print cookies
    def bdata(self,eslid,goodsid):
        binddata = [{"eslId": eslid,"goodsId":goodsid}]
        k = requests.post("http://192.168.2.127:8080/shopweb/bind",str(binddata),cookies = cookies)
        print k.json()
    def udata(self,eslid):
        ubdata = [{"eslId": eslid}]
        l = requests.post("http://192.168.2.127:8080/shopweb/unbind",str(ubdata),cookies = cookies)
        print l.json()
P= BindOpera()

n = 0
while True:
    n = n + 1
    P.udata(eslid[n])
    time.sleep(1)
    # P.bdata(eslid[n],goodsid[n])
    # time.sleep(2)
selenium | 阅读 2279 次
文章评论,共0条
游客请输入验证码