First of all, we determine the variable to be searched on youtube and get the codes on the search results page with the XMLHttp method.
We determine the codes between the tags with the GetContent function from the result.
With the split method, we parse the video url addresses in the list and get the video we want from the list.
A unique code that will be useful for product promotions and content creation.
Use it in good times :)
<% youtubequery="adidas shoe" Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP") url = "https://www.youtube.com/results?search_query="&youtubequery objHTTP.open "GET", url, False objHTTP.setRequestHeader "Content-Type", "text/html; charset=utf-8" objHTTP.send() txt = objHTTP.responseText Public Function GetContent(strContent, strPattern) Dim objRegExp, Matches Set objRegExp = New RegExp objRegExp.Pattern = strPattern objRegExp.IgnoreCase = True objRegExp.Global = True Set Matches = objRegExp.Execute(strContent) for each match in Matches GetContent = GetContent & match.Value next Set objRegExp = Nothing End Function videourl=(GetContent(txt,":"&chr(34)&"/watch"&chr(63)&"([\s\S]*?),")) listvideo=replace(replace(replace(videourl,chr(34),""),"/watch?v=",""),":","") youtubevideo = Split(listvideo,",") %> <%=youtubevideo(0)%> <%=youtubevideo(1)%> <%=youtubevideo(2)%>