ExMan

python api接口认证脚本

import requests

import sys
def acces_api_with_cookie(url_login, USERNAME, PASSWORD, url_access):
    # Start a session so we can have persistant cookies
    session = requests.session()
 
    # This is the form data that the page sends when logging in
    login_data = {
        \'username\': USERNAME,
        \'password\': PASSWORD,
        \'submit\'\'login\',
    }
 
    # Authenticate
    r = session.post(url_login, data=login_data)
 
    # Try accessing a page that requires you to be logged in
    r = session.get(url_access)
    print r.content
 
acces_api_with_cookie(\'http://127.0.0.1:88/accounts/login/\'\'admin\'\'123456\',
                      \'http://127.0.0.1:88/accounts/user_list/\')

分类:

技术点:

相关文章:

  • 2021-09-22
  • 2021-12-28
  • 2021-11-23
  • 2021-08-31
  • 2021-10-25
  • 2022-12-23
  • 2021-11-22
猜你喜欢
  • 2021-07-02
  • 2021-08-08
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-12-16
相关资源
相似解决方案