免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: smallstar001
打印 上一主题 下一主题

怎么下载网页内容 [复制链接]

论坛徽章:
0
31 [报告]
发表于 2008-12-26 16:01 |只看该作者
需要登陆的怎么办呢

论坛徽章:
0
32 [报告]
发表于 2008-12-26 16:02 |只看该作者
-u/--user <user:password>
              Specify  user and password to use when fetching. Read the MANUAL
              for detailed examples of how to use  this.  If  no  password  is
              specified, curl will ask for it interactively.

              You  can also use the --digest option to enable Digest authenti-
              cation when communicating with HTTP 1.1 servers.

              If this option is used several times, the last one will be used.

论坛徽章:
3
戌狗
日期:2014-09-10 17:07:162015年辞旧岁徽章
日期:2015-03-03 16:54:15wusuopu
日期:2016-06-17 17:43:45
33 [报告]
发表于 2008-12-26 16:04 |只看该作者
原帖由 smallstar001 于 2008-12-26 15:59 发表



我说的源码就是跟浏览器差不多,查看源代码 ,

我就是想找文本内容而已

我想也是。
那就需要先登录了。
wget有--post-data, 还有cookie相关的参数
                   # Log in to the server.  This can be done only once.
                   wget --save-cookies cookies.txt \
                        --post-data 'user=foo&password=bar' \
                        http://server.com/auth.php

                   # Now grab the page or pages we care about.
                   wget --load-cookies cookies.txt \
                        -p http://server.com/interesting/article

论坛徽章:
0
34 [报告]
发表于 2008-12-26 16:04 |只看该作者
原帖由 我是DBA 于 2008-12-26 16:00 发表
curl 加一个post参数,传递用户跟密码后就可以看到了。
不过先要看一下登陆的标签


举个例子吧

论坛徽章:
0
35 [报告]
发表于 2008-12-26 16:07 |只看该作者

论坛徽章:
0
36 [报告]
发表于 2008-12-26 16:14 |只看该作者
我是想找个bug, 这个bug记录到那么多连接的一个里面了

我不能一个个去找吧,我要找页面文本,然后找关键字

论坛徽章:
0
37 [报告]
发表于 2008-12-26 16:20 |只看该作者
没空帮你研究,用curl应该可以的,我们开发有用curl有用来抓网页。

论坛徽章:
0
38 [报告]
发表于 2008-12-26 16:22 |只看该作者
原帖由 ynchnluiti 于 2008-12-26 16:04 发表

我想也是。
那就需要先登录了。
wget有--post-data, 还有cookie相关的参数


这个是登陆页面  http://172.16.28.110/mantis/login_page.php

这个页面的代码
  1. <table class="width50" cellspacing="1">
  2. <tr>
  3.         <td class="form-title">
  4.                 登录        </td>
  5.         <td class="right">
  6.                 </td>
  7. </tr>
  8. <tr class="row-1">
  9.         <td class="category" width="25%">
  10.                 帐号        </td>
  11.         <td width="75%">
  12.                 <input type="text" name="username" size="32" maxlength="32" />
  13.         </td>
  14. </tr>
  15. <tr class="row-2">
  16.         <td class="category">
  17.                 密码        </td>
  18.         <td>
  19.                 <input type="password" name="password" size="16" maxlength="32" />
  20.         </td>
  21. </tr>
  22. <tr class="row-1">
  23.         <td class="category">
  24.                 记住此次登录        </td>
  25.         <td>
  26.                 <input type="checkbox" name="perm_login" />
  27.         </td>
  28. </tr>
  29. <tr>
  30.         <td class="center" colspan="2">
  31.                 <input type="submit" class="button" value="登录" />
  32.         </td>
  33. </tr>
  34. </table
复制代码


该怎么用wget登陆保存cookie,然后load cookie去下载其它网页的内容??

论坛徽章:
0
39 [报告]
发表于 2008-12-26 16:43 |只看该作者
原帖由 我是DBA 于 2008-12-26 16:30 发表
curl -d "username=用户名&password=密码&button=登录" http://172.16.28.110/mantis/login_page.php
用这个试试:)



我要下载的是其它的网页  curl会保存cookie么?

论坛徽章:
0
40 [报告]
发表于 2008-12-26 16:50 |只看该作者
算了 ,我在研究研究 andy分多  我就散给DBA算了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP