zoukankan      html  css  js  c++  java
  • python request 发送post 参数

    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import urllib2
    import urllib
    import cookielib
    import json
    import httplib
    import re
    import requests
    s=requests.session()
    print s.headers
    url = "https://licai.yingyinglicai.com/user/login.htm"
    headers={
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Host': 'licai.yingyinglicai.com',
        'Referer': 'https://licai.yingyinglicai.com/index.htm',
    }
    r = s.get(url,headers=headers)
    r=r.text
    #print s
    print type(r)
    r = r.encode('unicode-escape')
    print type(r)
    p = re.compile('.*token"s+value="(.*?)".*')
    m = p.match(r)
    token = m.group(1)
    print token
    
    login_url='https://licai.yingyinglicai.com/user/loginByPwd.do'
    data = {'cell': '18072722237', 'password': 'xxxx', 'token': token}
    #data = urllib.urlencode(data)
    response = s.post(login_url, data=data,headers=headers)
    print  response
    print response.status_code
    print response.content
    url='http://licai.yingyinglicai.com/index.htm'
    r= s.get(url,headers=headers)
    r = r.text
    print r
  • 相关阅读:
    kubernetes(七)二进制安装-worker节点安装
    kubernetes(六)二进制安装-master节点安装
    B树
    Nginx反向代理无法达到效果原因
    AVL树
    平衡二叉搜索树
    二叉搜索树
    二叉树
    js-day06-jQuery事件和DOM操作-练习题
    js-day05-JSON-jQuery初体验
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349194.html
Copyright © 2011-2022 走看看