火车采集器软件交流官方论坛

 找回密码
 加入会员
搜索
火车采集器V9版免费下载火车浏览器 - 可视采集,万能群发,全自动脚本工具
楼主: zhouchanglin

js post网站专区

[复制链接]
 楼主| 发表于 2011-2-12 19:22:24 | 显示全部楼层
回复 35# myj
下面是分页部分的代码,
  1. <span class="current">1</span>
  2.                           
  3.                           
  4.                           
  5.                           
  6.                           
  7.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '2', '');">2</a>
  8.                           
  9.                           
  10.                           
  11.                           
  12.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '3', '');">3</a>
  13.                           
  14.                           
  15.                           
  16.                           
  17.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '4', '');">4</a>
  18.                           
  19.                           
  20.                           
  21.                           
  22.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '5', '');">5</a>
  23.                           
  24.                           
  25.                           
  26.                           
  27.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '6', '');">6</a>
  28.                           
  29.                           
  30.                           
  31.                           
  32.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '7', '');">7</a>
  33.                           
  34.                           
  35.                           
  36.                           
  37.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '49', '');">...49</a>
  38.                           
  39.                           
  40.                           
  41.                           <a style="cursor:hand" onClick="doOrder('sale', 'desc', '2', '');"> >> </a>
  42.                           
  43.                           
  44.                           
  45.                         </div>
  46.                 </div>
  47.                  <!--翻页效果结束-->
复制代码
可以知道都是触发了doOrder()函数,在源码里就可以找到这个函数,路下
  1. //处理搜索按钮操作
  2. function doOrder(sort1, order, cur, browseWay) {
  3.         //alert(browseWay)
  4.         document.findLeeForm.sort.value = sort1;
  5.         document.findLeeForm.order.value = order;       
  6.         if(cur !=null && cur !=''){
  7.                 document.findLeeForm.cur.value = cur;
  8.         }
  9.         if(browseWay == null || browseWay == ''){
  10.                 document.findLeeForm.browseWay.value = browseWay;
  11.                 document.getElementById("picturePart").style.display="none";        //图片版部分隐藏
  12.             document.getElementById("photoPart").style.display="block";         //图文部分显示
  13.         }else if(browseWay == 'picture'){ //图片版
  14.                 document.findLeeForm.browseWay.value = browseWay;
  15.                
  16.                 document.getElementById("photoPart").style.display="none";                //图文版部分隐藏
  17.             document.getElementById("picturePart").style.display="block";         //图片部分显示
  18.         }
  19.         document.findLeeForm.submit();       
  20. }
复制代码
这个函数主要是提交了名字为findLeeForm的表单,传递4个参数sort1, order, cur, browseWay,以点第2页为例触发doOrder('sale', 'desc', '2', ''),这里可以知道sort1为sale,order代表排序desc降序,cur代表页码,browseWay是浏览模式,默认图文部分显示


findLeeForm的表单的源码
  1. <form name="findLeeForm" action="yellowPageLee.do" method="post">
  2.         <input type="hidden" name="searchFlg" value="leeSecondaryPage"/>
  3.         <input type="hidden" name="flag" value="0"/>       
  4.         <input type="hidden" name="sort"/>//----------------sale               
  5.         <input type="hidden" name="order"/>-------------------        desc
  6.         <input name="class2" type="hidden" value=""/>
  7.         <input name="merName" type="hidden" value=""/>
  8.         <input name="merProducer" type="hidden" value=""/>                       
  9.         <input name="merIssearchmer" type="hidden" value=""/>                       
  10.         <input name="merAcclimation" type="hidden" value=""/>                       
  11.         <input name="keyWord" type="hidden" value=""/>
  12.         <input name="merIsprescription" type="hidden" value=""/>
  13.         <input name="merSource" type="hidden" value=""/>
  14.         <input name="merFrom" type="hidden" value=""/>
  15.         <input name="cur" type="hidden"/>-------------2
  16.         <input name="class1" type="hidden" value="177"/>---------分类id,177感冒药品
  17.         <input name="browseWay" type="hidden"/>
  18.         <input name="keywords" type="hidden" value=""/>
  19. </form>
复制代码
这样获得分页的地址就是
  1. http://www.youjk.com/yellowPageLee.do?searchFlg=leeSecondaryPage&flag=0&sort=sale&order=desc&class2=&merName=&merProducer=&merIssearchmer=&merAcclimation=&keyWord=&merIsprescription=&merSource=&merFrom=&cur=页码&class1=177&browseWay=&keywords=
复制代码
这里主要就是cur,代表分页,路第49页就是http://www.youjk.com/yellowPageL ... eWay=&keywords=
 楼主| 发表于 2011-2-14 17:02:25 | 显示全部楼层
本帖最后由 zhouchanglin 于 2011-2-15 12:12 编辑

回复 39# flfgep2000

做好了,这个网站有2种翻页选择,点下一页,下拉框选择页码,我是用下拉框翻页,设置的post数据,不同的翻页post数据不同

做这类的网站主要看他页脚部分的代码,看 触发的函数,就能知道潞河请求的数据了,下面是第2页的页脚部分源码,
  1. <a id="ctl00_ContentPlaceHolder1_PageList2_1_linkFirst" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkFirst','')" style="font-size:12px;">首 页</a><font face="宋体">&nbsp;
  2.                         <a id="ctl00_ContentPlaceHolder1_PageList2_1_linkPrev" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkPrev','')" style="font-size:12px;">上一页</a>&nbsp;
  3.                         <a id="ctl00_ContentPlaceHolder1_PageList2_1_linkNext" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkNext','')" style="font-size:12px;">下一页</a>&=nbsp;
  4.                         <a id="ctl00_ContentPlaceHolder1_PageList2_1_linkLast" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkLast','')" style="font-size:12px;">尾 页</a></font>
  5.             </td>
  6.             <td align="right" colspan="1" style="width: 115px; height: 30px" valign="middle">
  7.                 <span style="font-size: 12px" class=''>转到:第</span><select name="ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage\',\'\')', 0)" id="ctl00_ContentPlaceHolder1_PageList2_1_ddlGotoPage" class="red" style="font-size:12px;color:red;">
  8.         <option selected="selected" value="1">1</option>
  9.         <option value="2">2</option>
  10.         <option value="3">3</option>
  11.         <option value="4">4</option>
  12.         <option value="5">5</option>
  13.         <option value="6">6</option>
  14.         <option value="7">7</option>
  15.         <option value="8">8</option>
  16.         <option value="9">9</option>
  17.         <option value="10">10</option>
  18.         <option value="11">11</option>
  19.         <option value="12">12</option>
  20.         <option value="13">13</option>
  21.         <option value="14">14</option>
  22.         <option value="15">15</option>
  23.         <option value="16">16</option>

  24. </select><span style="font-size: 12px" class=''>页</span>
复制代码
可以知道点首页触发
  1. __doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkFirst','')
复制代码
点上一页触发
  1. __doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkNext','')
复制代码
点下一页触发
  1. __doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkNext','')
复制代码
-----可以用这样翻页
尾页
  1. __doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkLast',''
复制代码
我规则里用的是下拉框翻页,下拉框翻页触发
  1. setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage\',\'\')', 0)
复制代码
可以知道点上下页,下拉框翻页逗是触发了__doPostBack函数,不同的是传递的参数,通过第一个参数判断是哪种请求

下面就是__doPostBack函数的源码
  1. var theForm = document.forms['aspnetForm'];
  2. if (!theForm) {
  3.     theForm = document.aspnetForm;-------------名字为aspnetForm的表单
  4. }
  5. function __doPostBack(eventTarget, eventArgument) {
  6.     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
  7.         theForm.__EVENTTARGET.value = eventTarget;--------------代表哪种请求,下拉框是ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage
  8.         theForm.__EVENTARGUMENT.value = eventArgument;--------------------可知道是空支付
  9.         theForm.submit();------------------------提交aspnetForm表单
  10.     }
复制代码
所以当下拉框翻页时,其实是提交aspnetForm的表单来完成的,这样把aspnetForm的表单的重要的元素&连接,提交给aspnetForm的表单提交地址http://www.hbnyw.com/News-List.aspx?TypeId=2就可以了,而当选择下拉框翻页时,最重要的是下拉框控件的值,即name为ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage的下拉框,就代表分页



这样post数据就是
  1. __EVENTTARGET=ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage&=__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=[POST随机值1]&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=[POST随机值2]&ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage=[分页]
复制代码
修改下下一页翻页这个地方:
下一页翻页的没有试,应该可以,post数据还是用下拉框参数代表分页的,然后服务器端把它加1就获得用户请求的页数了
下一页翻页的post数据
  1. __EVENTTARGET=ctl00$ContentPlaceHolder1$PageList2_1$linkNext&=__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=[POST随机值1]&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=[POST随机值2]&ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage=[分页]
复制代码
只是用下一页页数是错位的,总页数16,分页从1-15,第一页可能缺少

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?加入会员

x
发表于 2011-2-14 22:11:46 | 显示全部楼层
谢了,楼主,真的是麻烦你了。再次谢了
发表于 2011-2-14 22:56:26 | 显示全部楼层
mm.dd38.net
分页采集不全
 楼主| 发表于 2011-2-15 12:28:07 | 显示全部楼层
回复 44# summer3166

这个网站分页没有全部显示在第一页,虽然不能用分页的全部列出模式,但可以设置为上下页的方式

选择合适的开始,结束代码就可以获得全部的分页,这是我选取的《开始代码:
  1. <div class="page">
复制代码
结束代码:
  1. </div>
复制代码
试试可以不,分页的设置论坛里有教程的,你可以搜索相关的帖子
发表于 2011-2-15 23:01:00 | 显示全部楼层
http://www.bjmu.edu.cn/col/col4866/index.html

请 帮忙分析下这个能采集么?这个甚至都采不到内容页的列表。谢谢
 楼主| 发表于 2011-2-18 18:45:42 | 显示全部楼层
本帖最后由 zhouchanglin 于 2011-2-19 12:47 编辑

回复 46# being

http://www.bjmu.edu.cn/module/js ... B%E5%AD%A6%E9%83%A8


http://www.bjmu.edu.cn/module/js ... B%E5%AD%A6%E9%83%A8


可以看这个http://bbs.locoy.com/viewthread. ... mp;extra=#pid383751帖子,完全一样的处理函数,这个
发表于 2011-2-18 23:51:17 | 显示全部楼层
楼主帮忙给做个规则。
http://searchjob.chinahr.com/
这个抓包,看源代码都一头雾水,不知道怎么弄。
采集网址规则没做出来;采集内容规则里“公司规模”之类的则从别的网页里调用。
发表于 2011-2-18 23:56:38 | 显示全部楼层
请楼主帮忙做个规则
http://searchjob.chinahr.com/
抓包,看源代码,都没能解决。
网址采集规则做不出来,分页抓包,结果一样,不清楚是什么原因,页面内容采集规则里想公司规模之类的从别的网页调用,不知道怎么写规则。
发表于 2011-2-18 23:58:14 | 显示全部楼层
请楼主帮忙做个规则
http://searchjob.chinahr.com/
抓包,看源代码,都没能解决。
网址采集规则做不出来,分页抓包,结果一样,不清楚是什么原因,页面内容采集规则里想公司规模之类的从别的网页调用,不知道怎么写规则。
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

QQ|手机版|Archiver|火车采集器官方站 ( 皖ICP备06000549 )

GMT+8, 2024-10-7 04:26

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表