zhouchanglin
发表于 2011-2-12 19:22:24
回复 35# myj
下面是分页部分的代码, <span class="current">1</span>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '2', '');">2</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '3', '');">3</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '4', '');">4</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '5', '');">5</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '6', '');">6</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '7', '');">7</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '49', '');">...49</a>
<a style="cursor:hand" onClick="doOrder('sale', 'desc', '2', '');"> >> </a>
</div>
</div>
<!--翻页效果结束-->可以知道都是触发了doOrder()函数,在源码里就可以找到这个函数,路下//处理搜索按钮操作
function doOrder(sort1, order, cur, browseWay) {
//alert(browseWay)
document.findLeeForm.sort.value = sort1;
document.findLeeForm.order.value = order;
if(cur !=null && cur !=''){
document.findLeeForm.cur.value = cur;
}
if(browseWay == null || browseWay == ''){
document.findLeeForm.browseWay.value = browseWay;
document.getElementById("picturePart").style.display="none"; //图片版部分隐藏
document.getElementById("photoPart").style.display="block"; //图文部分显示
}else if(browseWay == 'picture'){ //图片版
document.findLeeForm.browseWay.value = browseWay;
document.getElementById("photoPart").style.display="none"; //图文版部分隐藏
document.getElementById("picturePart").style.display="block"; //图片部分显示
}
document.findLeeForm.submit();
}这个函数主要是提交了名字为findLeeForm的表单,传递4个参数sort1, order, cur, browseWay,以点第2页为例触发doOrder('sale', 'desc', '2', ''),这里可以知道sort1为sale,order代表排序desc降序,cur代表页码,browseWay是浏览模式,默认图文部分显示
findLeeForm的表单的源码<form name="findLeeForm" action="yellowPageLee.do" method="post">
<input type="hidden" name="searchFlg" value="leeSecondaryPage"/>
<input type="hidden" name="flag" value="0"/>
<input type="hidden" name="sort"/>//----------------sale
<input type="hidden" name="order"/>------------------- desc
<input name="class2" type="hidden" value=""/>
<input name="merName" type="hidden" value=""/>
<input name="merProducer" type="hidden" value=""/>
<input name="merIssearchmer" type="hidden" value=""/>
<input name="merAcclimation" type="hidden" value=""/>
<input name="keyWord" type="hidden" value=""/>
<input name="merIsprescription" type="hidden" value=""/>
<input name="merSource" type="hidden" value=""/>
<input name="merFrom" type="hidden" value=""/>
<input name="cur" type="hidden"/>-------------2
<input name="class1" type="hidden" value="177"/>---------分类id,177感冒药品
<input name="browseWay" type="hidden"/>
<input name="keywords" type="hidden" value=""/>
</form>这样获得分页的地址就是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/yellowPageLee.do?searchFlg=leeSecondaryPage&flag=0&sort=sale&order=desc&class2=&merName=&merProducer=&merIssearchmer=&merAcclimation=&keyWord=&merIsprescription=&merSource=&merFrom=&cur=49&class1=177&browseWay=&keywords=
zhouchanglin
发表于 2011-2-14 17:02:25
本帖最后由 zhouchanglin 于 2011-2-15 12:12 编辑
回复 39# flfgep2000
做好了,这个网站有2种翻页选择,点下一页,下拉框选择页码,我是用下拉框翻页,设置的post数据,不同的翻页post数据不同
做这类的网站主要看他页脚部分的代码,看 触发的函数,就能知道潞河请求的数据了,下面是第2页的页脚部分源码, <a id="ctl00_ContentPlaceHolder1_PageList2_1_linkFirst" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkFirst','')" style="font-size:12px;">首 页</a><font face="宋体">
<a id="ctl00_ContentPlaceHolder1_PageList2_1_linkPrev" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkPrev','')" style="font-size:12px;">上一页</a>
<a id="ctl00_ContentPlaceHolder1_PageList2_1_linkNext" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkNext','')" style="font-size:12px;">下一页</a>&=nbsp;
<a id="ctl00_ContentPlaceHolder1_PageList2_1_linkLast" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkLast','')" style="font-size:12px;">尾 页</a></font>
</td>
<td align="right" colspan="1" style="width: 115px; height: 30px" valign="middle">
<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;">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
</select><span style="font-size: 12px" class=''>页</span>可以知道点首页触发__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkFirst','')点上一页触发__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkNext','')点下一页触发__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkNext','')-----可以用这样翻页
尾页__doPostBack('ctl00$ContentPlaceHolder1$PageList2_1$linkLast',''我规则里用的是下拉框翻页,下拉框翻页触发setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage\',\'\')', 0)可以知道点上下页,下拉框翻页逗是触发了__doPostBack函数,不同的是传递的参数,通过第一个参数判断是哪种请求
下面就是__doPostBack函数的源码var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;-------------名字为aspnetForm的表单
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;--------------代表哪种请求,下拉框是ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage
theForm.__EVENTARGUMENT.value = eventArgument;--------------------可知道是空支付
theForm.submit();------------------------提交aspnetForm表单
}所以当下拉框翻页时,其实是提交aspnetForm的表单来完成的,这样把aspnetForm的表单的重要的元素&连接,提交给aspnetForm的表单提交地址http://www.hbnyw.com/News-List.aspx?TypeId=2就可以了,而当选择下拉框翻页时,最重要的是下拉框控件的值,即name为ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage的下拉框,就代表分页
这样post数据就是__EVENTTARGET=ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage&=__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=&ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage=[分页]修改下下一页翻页这个地方:
下一页翻页的没有试,应该可以,post数据还是用下拉框参数代表分页的,然后服务器端把它加1就获得用户请求的页数了
下一页翻页的post数据__EVENTTARGET=ctl00$ContentPlaceHolder1$PageList2_1$linkNext&=__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=&ctl00$ContentPlaceHolder1$PageList2_1$ddlGotoPage=[分页]只是用下一页页数是错位的,总页数16,分页从1-15,第一页可能缺少
flfgep2000
发表于 2011-2-14 22:11:46
谢了,楼主,真的是麻烦你了。再次谢了
summer3166
发表于 2011-2-14 22:56:26
mm.dd38.net
分页采集不全
zhouchanglin
发表于 2011-2-15 12:28:07
回复 44# summer3166
这个网站分页没有全部显示在第一页,虽然不能用分页的全部列出模式,但可以设置为上下页的方式
选择合适的开始,结束代码就可以获得全部的分页,这是我选取的《开始代码:<div class="page">结束代码:</div>试试可以不,分页的设置论坛里有教程的,你可以搜索相关的帖子
being
发表于 2011-2-15 23:01:00
http://www.bjmu.edu.cn/col/col4866/index.html
请 帮忙分析下这个能采集么?这个甚至都采不到内容页的列表。谢谢
zhouchanglin
发表于 2011-2-18 18:45:42
本帖最后由 zhouchanglin 于 2011-2-19 12:47 编辑
回复 46# being
http://www.bjmu.edu.cn/module/jslib/jquery/jpage/dataproxy.jsp?startrecord=1&endrecord=19&perpage=19&appid=1&webid=1&path=%2F&columnid=4866&unitid=117&webname=%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6%E5%8C%BB%E5%AD%A6%E9%83%A8
http://www.bjmu.edu.cn/module/jslib/jquery/jpage/dataproxy.jsp?startrecord=1&endrecord=100&perpage=100&appid=1&webid=1&path=%2F&columnid=4866&unitid=117&webname=%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6%E5%8C%BB%E5%AD%A6%E9%83%A8
可以看这个http://bbs.locoy.com/viewthread.php?tid=58756&page=1&extra=#pid383751帖子,完全一样的处理函数,这个
gapo83
发表于 2011-2-18 23:51:17
楼主帮忙给做个规则。
http://searchjob.chinahr.com/
这个抓包,看源代码都一头雾水,不知道怎么弄。
采集网址规则没做出来;采集内容规则里“公司规模”之类的则从别的网页里调用。
gapo83
发表于 2011-2-18 23:56:38
请楼主帮忙做个规则
http://searchjob.chinahr.com/
抓包,看源代码,都没能解决。
网址采集规则做不出来,分页抓包,结果一样,不清楚是什么原因,页面内容采集规则里想公司规模之类的从别的网页调用,不知道怎么写规则。
gapo83
发表于 2011-2-18 23:58:14
请楼主帮忙做个规则
http://searchjob.chinahr.com/
抓包,看源代码,都没能解决。
网址采集规则做不出来,分页抓包,结果一样,不清楚是什么原因,页面内容采集规则里想公司规模之类的从别的网页调用,不知道怎么写规则。
页:
1
2
3
4
[5]
6
7
8
9
10
11
12
13
14