Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5705205
  • 博文数量: 675
  • 博客积分: 20301
  • 博客等级: 上将
  • 技术积分: 7671
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-31 16:15
文章分类

全部博文(675)

文章存档

2012年(1)

2011年(20)

2010年(14)

2009年(63)

2008年(118)

2007年(141)

2006年(318)

分类:

2006-08-03 20:44:50

校园网ip网费查询脚本的分析
这个脚本原来是bbs上的一个帖子,我拿出来作为学习curl的资料。

设置cookie,如下:

[jasonh@fbsd bin]$ ./curl.sh
所剩余额: 109.00

[jasonh@fbsd bin]$ cat curl.sh
curl -d 'fr=00&id_ip=YOUR_IP&pass=YOUR_PASSWD&set=%BD%F8%C8%EB' \
        -L -D hitsun.cookie \
        -b hitsun.cookie 2>&1 |
sed -n 's/^.*\(所剩余额\)\([^0-9]*\)\([0-9.]*\).*/\1: \3/p'

命令分析:

curl

 -d/--data    HTTP POST data (H)
    --data-ascii    HTTP POST ASCII data (H)
    --data-binary   HTTP POST binary data (H)
    --negotiate     Enable HTTP Negotiate Authentication (H)
    --digest        Enable HTTP Digest Authentication (H)
    --disable-eprt  Prevent curl from using EPRT or LPRT (F)
    --disable-epsv  Prevent curl from using EPSV (F)

 -L/--location      Follow Location: hints (H)
    --location-trusted Follow Location: and send authentication even
                    to other hostnames (H)

 -D/--dump-header Write the headers to this file
    --egd-file EGD socket path for random data (SSL)
    --tcp-nodelay   Set the TCP_NODELAY option

 -b/--cookie Cookie string or file to read cookies from (H)
    --basic         Enable HTTP Basic Authentication (H)



今天花了好长时间搞这个cookie,总算是明白了一些。
curl -d 'fr=00&id_ip=YOUR_IP&pass=YOUR_PASSWD&set=%BD%F8%C8%EB' \
        -L -c hitsun.cookie

再用cookie进行登录的时候,出现了一些问题。
cookie -b hitsun.cookie
结果不对,返回的不是收费的页面,还是登录页面,即使加上-L参数还是不行。

最后,cliff出马,搞定。“姜还是老的辣”!

那个收费页面跟登录页面不是一个,名字是profile.php,通过手工登录就可以看出来。

cookie -b hitsun.cookie

就可以正常的返回收费页面了。
阅读(3409) | 评论(0) | 转发(0) |
0

上一篇:curl的Manual

下一篇:curl的又一应用

给主人留下些什么吧!~~