storeProxy.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:searchForAll 作者: MemoryAndDream 项目源码 文件源码
def upgradeWiseproxy(proxys):
    '''?? ????wiseproxy ????wiseproxy'''
    dir_r =  os.path.dirname(os.path.abspath(__file__))
    etc_c = os.path.join(dir_r, 'wiseproxy.conf')
    print etc_c
    cf = ConfigParser.ConfigParser()
    cf.read(etc_c)
    login_url = cf.get('main', 'login_url')
    api_url = cf.get('main', 'api_url')
    usr_pwd_data = eval(cf.get('main', 'usr_pwd_data'))
    headers = {'Content-type': 'application/x-www-form-urlencoded', 'charset': 'utf-8'}
    # login
    cj = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    req = urllib2.Request(login_url, urlencode(usr_pwd_data), headers)
    opener.open(req)
    #delete old proxy
    queryurl='http://wiseproxy.ops.vobile.org/getProxyList?partitionSearch=buy&proxySearch=&_search=false&nd=1503380267574&rows=500&page=1&sidx=&sord=asc'
    #http://wiseproxy.ops.vobile.org/getProxyList?partitionSearch=&proxySearch=120.55.115.209:63267&_search=false&nd=1503563948157&rows=10&page=1&sidx=&sord=asc
    oldproxys = opener.open(queryurl).read()
    oldproxys=json.loads(oldproxys)
    oldproxylist=oldproxys['rows']
    for oldproxy in oldproxylist:
        proxyid =  oldproxy['id']
        print proxyid

    sys.exit()
    if type(proxys)==type([]):
        # addproxy
        for proxy in proxys:
            data = {"partition": "9509", "proxyId": -1, "proxyServerInfo": proxy, "source": "Vultr"}
            request = urllib2.Request(api_url, urlencode(data), headers)
            response = opener.open(request)
    else:
        data = {"partition": "9509", "proxyId": -1, "proxyServerInfo": proxys, "source": "Vultr"}
        request = urllib2.Request(api_url, urlencode(data), headers)
        response = opener.open(request)
    opener.close()

#upgradeWiseproxy('192.168.200.252:3127')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号