[求助] asp采集问题,被这问题卡住两天了解决不了,求高人指点

aliang 2013-10-23 12:05:54
通过采集默认页源码,然后在这个页面中取出最大页数,然后遍历读取每个分页内容
第一页能正常采集,其它页面都采集不到数据,附上能正常运行的代码,请下载帮我分析下哪问题,在线等,万分感谢
麻烦移动,到百度网盘下载下整个文件
下载地址:http://pan.baidu.com/s/146gmx 密码:stus
...全文
132 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aliang 2013-10-23
  • 打赏
  • 举报
回复
应该跟抓取速度没有关系吧demo1(),我是直接把要采集的页放在数组里面,然后直接采集,这个比demo1的采集速度(频率)更快才对啊,不知道会不会跟cookies有关系

Sub Demo1()
        arrUrl=""&_
        "http://cn.mouser.com/Search/Refine.aspx?N=1323043&Keyword=ATSAM&FS=True"&vbcrlf&_
        "http://cn.mouser.com/Search/Refine.aspx?N=1323043&Keyword=ATSAM&No=25&FS=True"&vbcrlf&_
        "http://cn.mouser.com/Search/Refine.aspx?N=1323043&Keyword=ATSAM&No=50&FS=True"&vbcrlf&_
        "http://cn.mouser.com/Search/Refine.aspx?N=1323043&Keyword=ATSAM&No=75&FS=True"
        Response.Write("<div style='height:500px; width:1000px; overflow:scroll; padding:15px;border:2px solid #ccc'>")
        arrUrl=Split(arrUrl,vbcrlf)
        Set http=New jm_ClsThief
        http.Charset="utf-8"
        For i=0 To uBound(arrUrl)
                url=arrUrl(i)
                Response.Write("第"&i+1&"页 <a href='"&url&"' target=_blank>"&url&"</a><br>")
                content=http.GetBody(url)
                content=http.Cut(content,"<tr class=""SearchResultsRowOdd"">","<!--- Search Tips --->","[@")
                Mouser_Page()
        Next
        Response.Write("</div>")
End Sub
Sub Demo2()
        Response.Write("<div style='height:500px; width:1000px; overflow:scroll; padding:15px;border:2px solid red'><h1 style=color:red>Demo2 这里面测试有问题,说页面不存在,只有第一页能正常采集,其他页采集不到,通过第一页获取总页数,然后遍历种个分页,循环采集</h1>")
        url="http://cn.mouser.com/Search/Refine.aspx?N=1323043&Keyword=ATSAM&FS=True"
        Set http=New jm_ClsThief
        http.Charset="utf-8"
        http.IsDebug=true
        content=http.GetBody(url)
        content=http.Cut(content,"<tr class=""SearchResultsRowOdd"">","<!--- Search Tips --->","[@")
        
        '取搜索数据总页数及网址
        arrData=http.GetArray("href=""[^>]+"">(\d+)<\/a><a id=""ctl00_ContentMain_PagerBottom_lnkNext"" href=""([^>]+)"">下一页",content,0,1)
        If http.Found Then
                flag=http.Found : page=Trim(arrData(0,0)) : pageUrl="http://cn.mouser.com"&unescape(Rtrim(arrData(0,1)))
                Response.Write("<h5>共"&page&"页 "&pageUrl&"</h5>")
        End If
        Response.Write("第1页 <a href='"&url&"' target=_blank>"&url&"</a><br>")
        Mouser_Page()
        If flag Then
                For i=2 To Page
                        j=i-1
                        pageUrl=RegReplace("No=\d+",pageUrl,"No="&j*25,1,1)
                        Response.Write("第"&i&"页 <a href='"&pageUrl&"' target=_blank>"&pageUrl&"</a><br>")
                        content=http.GetBody(pageUrl)
                        If content<>"<!--null-->" Then
                                content=http.Cut(content,"<tr class=""SearchResultsRowOdd"">","<!--- Search Tips --->","[@")
                                Mouser_Page()
                        End If
                Next
        End If
        Response.Write("</div>")
End Sub
aliang 2013-10-23
  • 打赏
  • 举报
回复
蓝色理想论坛的网友帮我解决了问题
YiYanXiYin 2013-10-23
  • 打赏
  • 举报
回复
每页的Request Header中除了url中no不一样,还有Cookie不一样, 可能是这个原因

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧