Get the App
SLTechnology News&Howtos  ›  Development  › 

How js+AJAX asynchronously collects all videos and information from Youku albums

Shulou Source: shulou.com Published: 2022-06-03 05:37:27 11月17日 Update

This article mainly introduces how js+AJAX asynchronously collects all videos and information from Youku albums, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

Code

JavaScipt AJAX & regular expression test

Function wrt (s) {

Subret.value = s + "\ n" + subret.value

/ / subret.value + = "\ n" + s

}

Var objRequest; / / define a XML request object

Var previd = "", nowid = 0pr 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\ swords =\ s * "(\ d +)"\ s match /) [1]

Vtitle = webstr.match (/ (. +)-(. +)-Video-Youku Video-online viewing (-)? /) [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 initializes the XMLHTTP object

ObjRequest.onreadystatechange = retweb; / / Asynchronous callback method

ObjRequest.open ("GET", uJing true)

ObjRequest.send (null)

}

Function tstart () {

If (listid== "") {

Listid=getlid ()

}

Url = "http://v.youku.com/v_playlist/f" + listid +" o1p "+ nowid +" .html "

Getweb (url)

}

# star

Tags: Videos code articles albums and information objects pages differences individuals values interests compatibility variables at the same time online viewing customers clients methods time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi Shulou Information vpn Docker