利用Linux的shell脚本完成模拟登录且获取数据

直接上代码

#!/bin/bash

#
# -b/ --cookie 
#  (HTTP) Pass the data to the HTTP server as a cookie.
# -c/ --cookie-jar 
#  Specify to which file you want curl to write all cookies
# -d/ --data 
#  (HTTP) Sends the specified data in a POST request to the HTTP server
# -L/ --location 
#  auto redirect while need
#

# parameter init
#

UID=18502125×××
PWD=dc96a290a42c7ec8d090e7e000970b4e
URL="https://××.××××.com/action/index.php"

# login
curl -L -c traffic.txt --user-agent Mozilla/5.0 -d "action=login_web&data[username]=${UID}&data[password]=${PWD}" ${URL} > login.log

# get list
curl -c traffic.txt -b traffic.txt --user-agent Mozilla/5.0 -d "action=card_list_load&data[party]=0&data[start]=0&data[count]=30" ${URL} > data.txt

 

posted @ 2016-08-12 16:36  再見理想  阅读(1441)  评论(0编辑  收藏  举报