• 周末没事,在重庆网通看连续剧,不过他没有提供一个很好的列表页面,一个列表页面没有提供翻页功能,只有700个电影列表,不能看到以前的连续剧。一个页面有翻页,但是每页只有10个影片,连续剧有200多个页面,要看以前的连续剧也要翻页很多次,在 [原创]Ajax基本原理讲解 里面的程序的基础上修改了一下,获取了所以连续剧的列表,方便观看。

    大致原理如下:

  • 用xmlhttp获取第一页源文件。
  • 从源文件中提取影片的标题和地址,在页面中显示
  • 获取下一页的源文件,提取标题和地址并显示。
  • 重复,直到最后一页

源代码写得很乱,仅供参考。下载: cqcnc.zip


<HTML>
<HEAD>
<TITLE> 网通电影地址 </TITLE>
<META NAME="Author" CONTENT="http://pharaoh.cnblogs.com">
</HEAD>
<BODY>

<div id=load style="display:none; position:absolute;right:0px;top:0px;background:#FF5B5B;border:1px solid">正在加载</div> 


<input id=wurl style="width:500px" value="http://cncxp.cqwin.com/mov_list.asp?page={0}&class2id=9&Nclassid=&order=&updown=">
开始页:<input id=pagestart value='1'style="width:50px" />结束页:<input id=pageend value="216" style="width:50px" />
<button onclick="Begin();">加载</button>
<button onclick="stop();">停止</button>
<!--
<hr />
<div id=city>片断</div>
<hr />
<center><div id="wuhan_weather">数据区域</div></center>
<hr />
<div id=stext>代码区</div>
-->
<script language="javascript">
    var loading = false;
    var bgTime;
    function Begin()
    {
        bgTime = new Date();
        InsertHtml('<br />开始时间:'+bgTime);
        loading = true;
        GetWeather();
    }
  function stop()
  {
      loading = false;
  }
 var xmlhttp ;
 function InsertHtml(html)
 {
     
     document.body.insertAdjacentHTML('beforeEnd',html);
}
 function GetWeather()
 {
         if(!loading) return;
     if(parseInt(document.getElementById('pagestart').value,10) > parseInt(document.getElementById('pageend').value,10)) 
     {
         var endTime = new Date();
         InsertHtml('<br />结束时间:'+endTime+"<br />用时:"+(endTime - bgTime)/1000+"秒");
         return;
     }
         window.status = '';
         document.all("load").style.display='';
         if(!xmlhttp)
         {
     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     xmlhttp.onreadystatechange = getReady;
    }
     xmlhttp.Open("GET",document.getElementById('wurl').value.replace('{0}',document.getElementById('pagestart').value),true);
     xmlhttp.Send();
}
function getReady()
{
    window.status += xmlhttp.readyState+' ';
   if(xmlhttp.readyState == 4)
   {
       document.all("load").style.display='none';
     if(xmlhttp.status == 200)
     {
        var xmlReturn = bytes2BSTR(xmlhttp.ResponseBody);  //xmlhttp.responseText;

        //document.all("wuhan_weather").innerHTML=xmlReturn;
        //document.all("stext").innerText=xmlReturn;
        
    
        var newText = xmlReturn;//xmlReturn.replace(/\n+/g,' ');
        //document.all("stext").innerText=newText;
        var re = /<a class="date".+?a>/ig;
        var cityText = newText.match(re);
        var page = document.getElementById('pagestart').value;
        var alink = '<hr /><a href="'+document.getElementById('wurl').value.replace('{0}',page)+'" target="_blank">第'+page+'页';
        for(var i=0;i<cityText.length;i++)
        {
            alink +='<br />'+ cityText[i].replace('href="list.asp','target=_blank href="http://cncxp.cqwin.com/list.asp');
        }
        //document.all("city").innerHTML=cityText[2];
        //document.all("city").innerHTML=alink;
        InsertHtml(alink);
        
        document.getElementById('pagestart').value = parseInt(document.getElementById('pagestart').value,10)+1;
        xmlhttp = null;
        GetWeather();
     }
     else
     {
             window.status = '出现错误:'+ xmlhttp.statusText+"  "+xmlhttp.status;
             xmlhttp = null;
            window.setTimeout(GetWeather,10000);
       
     }
     //xmlhttp = null;
   }

}

</script>
        <script language="vbscript"> 
        <!--
            Function bytes2BSTR(vIn) 
                strReturn = "" 
                For i = 1 To LenB(vIn) 
                    ThisCharCode = AscB(MidB(vIn,i,1)) 
                    If ThisCharCode < &H80 Then 
                        strReturn = strReturn & Chr(ThisCharCode) 
                    Else 
                        NextCharCode = AscB(MidB(vIn,i+1,1)) 
                        strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) 
                        i = i + 1 
                    End If 
                Next 
                bytes2BSTR = strReturn 
            End Function 
            -->
        </script>
</BODY>
</HTML>

转载于:https://www.cnblogs.com/Pharaoh/archive/2006/03/21/354713.html

用Ajax获取网通电影列表。相关推荐

  1. list vue 添加数据方法_vue ajax获取数据填充列表,增加,删除

    Document 添加品牌 Name: IdNameCtimeOperation {{item.id}}{{item.name}}{{item.ctime}} 删除 // 如果我们通过全局配置了,请求 ...

  2. 图解微信小程序---获取电影列表

    图解微信小程序---获取电影列表 代码笔记 list跳转 第一步:编写前端页面获取相关的电影列表参数(对于显示参数不熟悉,可以先写js,通过console  Log的方式获取我们电影的相关数据字段,后 ...

  3. 笔记-返回到前一个页面时显示前一个页面中ajax获取的数据

    笔记第一部分:http://www.cnblogs.com/zczhangcui/p/6869219.html 在第一部分遇到的问题是,用ajax获取了一系列列表信息后,拼接好html后插入到了原有页 ...

  4. ajax怎样获得表头信息,layui.table动态获取表头和列表数据示例

    layui.table动态获取表头和列表数据示例 2020年07月14日 | 萬仟网IT编程 | 我要评论 ```javascript//表格layui.use('table', function() ...

  5. vue 后台数据列表获取图片_vue使用ajax获取后台数据进行显示的示例

    实例如下所示: title #th th{ background-color: #50a9fa; color: aliceblue; font-size: large; } 添加数据 编号 名称 时间 ...

  6. 通过AJAX获取数据列表

    前端代码: <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF- ...

  7. AngularJS学习笔记(3)——通过Ajax获取JSON数据

    通过Ajax获取JSON数据 以我之前写的与用户交互的动态清单列表为例,使用JSON前todo.html代码如下: <!DOCTYPE html> <html ng-app=&quo ...

  8. Bootstrap4+MySQL前后端综合实训-Day08-PM【ajax获取表单标签内容、根据“栏目信息”添加“新闻信息”、新闻管理系统-项目展示】

    [Bootstrap4前端框架+MySQL数据库]前后端综合实训[10天课程 博客汇总表 详细笔记][附:实训所有代码] 目   录 ajax获取表单标签内容 ajax根据数据库加载select下来列 ...

  9. python豆瓣mysql_python爬虫获取豆瓣电影——Python操作MySQL存储数据

    30 May 2015 爬虫抓到的数据需要存储到MySQL中,所以我们需要熟悉下使用Python操作MySQL数据库.首先你的机器上要安装MySQLdb,MySQLdb是用于Python连接Mysql ...

最新文章

  1. 雨中的蚊子为啥不会被雨滴砸死?
  2. Spring框架的事务管理的基本概念
  3. JDBC常用API小结
  4. c语言标识符的文法表示,第三章文法和语法[lly]3.ppt
  5. 【收集】Python 微优化
  6. WordPress更改“固定链接”后 页面404原因及解决方法(Nginx版)
  7. jQuery插件imageTick实现复选和单选框转化为图片
  8. UGUI 优化关于图集,排序等
  9. ionic cordova 热更新
  10. 利用metadata-extractor定向获取图片拍摄时间以及宽高
  11. 利用c++深究周立功usbcan盒的学习
  12. centos7上面安装geany编辑器
  13. 等保三级核心-主机安全
  14. Hive的nvl、coalesce、if、nvl2
  15. 2019.12.31罗振宇2020年跨年演讲《时间的朋友》精华全文版本——思维决定一个人的上限,能力决定一个人的下限
  16. lqc_远程日志管理
  17. Just to myself
  18. 推荐 7 个热门电商 GitHub 项目
  19. LB集群--LVS部署
  20. div的背景被body的背景遮蔽了。。。。。

热门文章

  1. 服务器返回400错误
  2. Leo支招:高层跳槽,三宜三忌
  3. java做出毛玻璃效果_手把手教你CSS如何实现毛玻璃效果
  4. C和C++的开发工具
  5. Qt 反射机制实现,通过类名创建对象
  6. FMX Windows下无边框窗口处理
  7. 2021年中国露营行业市场现状分析:行业发展迅猛[图]
  8. vmware 添加共享盘
  9. 阿里云大学笔记——K-Means聚类算法
  10. 第七课 渐变工具和油漆桶工具