python post提交

 1 # coding:utf8
 2 import requests
 3 def login():
 4     url = 'http://back.xiyilang.cc/staff/login.json'
 5     headers={'X-Forwarded-For':'127.0.0.1'} #ip转化
 6     data={
 7         'staffCode':'00025', #用户
 8         'password':'123456',#密码
 9     }
10     x = requests.post(url,data,headers=headers) #登陆账号密码
11     cookie = x.cookies  #cookie=cookies 获取cookie等待下次调用
12     return cookie
13 cookie = login()
14 def lvaue(id):
15     url = 'http://back.xiyilang.cc/admin/staff-admin!search.json'
16     headers = {'X-Forwarded-For': '127.0.0.1'}
17     data = {
18         'staffId':id,
19     }
20     x = requests.post(url,data,headers=headers,cookies=cookie).text #再次进行调用cookie
21     print x
22 y=raw_input('id:')
23 lvaue(y)

*

input()  #危险  __import__('os').system('dir') 可执行

raw_imput()

input() 本质上还是使用 raw_input() 来实现的,只是调用完 raw_input() 之后再调用 eval() 函数,所以,你甚至可以将表达式作为 input() 的参数,并且它会计算表达式的值并返回它。

不过在 Built-in Functions 里有一句话是这样写的:Consider using the raw_input() function for general input from users.

除非对 input() 有特别需要,否则一般情况下我们都是推荐使用 raw_input() 来与用户交互

 

posted @ 2017-05-11 22:50  archie’s  阅读(494)  评论(0编辑  收藏  举报