Ajax asynchronous favorably cool albums capture all video and information (JavaScript code) _javascript Tips

Source: Internet
Author: User
Personally feel not very satisfied, because vb.net in the. NET environment to perform the collection, the resulting network connection and regular matching consumption is too large, and my final application is in the video collection submission, so consider using JS ajax+ Regular expression to achieve this goal.
Have not been systematically learning JS and regular, so spend more time than expected, tossing a night, fooled the following code. =.. =
Copy Code code as follows:

<!--
Night Smell Incense Original, reproduced please retain this information, thank you very much!
Blog: http://clso.cnblogs.com
Home: http://cleclso.cn
qq:315514678 e-mail:clso#qq.com
Welcome to the Technical Exchange!
-->

<title>javascipt AJAX & Regular Expression test</title>
<script type= "Text/javascript" language= "JavaScript" >
function wrt (s) {
Subret.value = s + "\ n" + subret.value;
Subret.value + = "\ n" + s;
}
var objrequest; Define an XML Request object
var previd = "", Nowid =0,listid = "", Iscancel=false; Other variables
function Getlid () {
var Listid = Weburl.value.match (/playlist_show\/.* (? =id_ (\d+)). *\.html$/i);
if (!listid) {
return null;
} else {
return listid[1];
}
}
function Retweb () {
if (objrequest.readystate = = 4 && objrequest.status = 200) {
Get callback
var webstr = Objrequest.responsetext;
vid = Webstr.match (/var\s+videoid\s*=\s* "(\d+)" \s*;/) [1];
Vtitle = Webstr.match (/<title> (. +)-(. +)-video-Youku video-watch Online (-) <\/title>/) [2];
WRT (Nowid + ":" + vtitle + "=" + vid);
if (Previd = = vid) return;
Previd = vid;
Nowid + 1;
Start a new cycle
if (iscancel) return;
Tstart ();
} else {
Alert ("Callback failed!") ");
return;//"Error:" + Objrequest.statustext;
}
}
function Getweb (u) {
objrequest = new XMLHttpRequest (); New ActiveXObject ("Msxml2.xmlhttp"); Ie5&6 Initialize XMLHTTP Object
Objrequest.onreadystatechange = Retweb; Asynchronous callback method
Objrequest.open ("Get", u,true);
Objrequest.send (NULL);
}
function Tstart () {
if (listid== "") {
Listid=getlid ();
}
url = "http://v.youku.com/v_playlist/f" + Listid + "o1p" + Nowid + ". html";
Getweb (URL);
}

</script>
<body>
<input type= "text" id= "Weburl" value= "http://www.youku.com/playlist_show/id_2350764.html" style= "width:640"/ ><br/>
<textarea id= "Subret" readonly= "readonly" style= "width:640"; height:360; " > #star </textarea>
<br/>
<input Type=button value= "start to extract the album" Onclick= "if (iscancel) Iscancel=false;tstart ();"/>
<input Type=button value= "Clear text" onclick= "subret.value="; Nowid =0;preid= '; listid= ';/>
<input Type=button value= "suspend" onclick= "Iscancel=true"/>
</body>

The idea is basically the same as last time, so I don't have to repeat it.
With vb.net a page collection time is generally about 1 seconds, and this code relies on client script, each page collection in 0.3~0.5 seconds, according to the user's computer configuration and different.
The individual uses the IE7 test to pass, but the code is more casual, so the compatibility is not very good. If you need to use, please modify the code yourself.
Night Smell Incense Original, reprint please keep this information
Blog: http://clso.cnblogs.com/
Home: http://www.cleclso.cn/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.