Searching video on Youtube !

Macros tutorials, Sharing your good scripts to everyone!
Post Reply
daniel
Site Admin
Posts: 238
Joined: Fri Feb 23, 2018 10:50 am

Searching video on Youtube !

Post by daniel » Wed May 23, 2018 9:40 am

Hi, this is script for searching video on youtube with a random keyword from 2 keywords ("bypass captcha 9hits" and "google search 9hits"). Then click to the video if found in the search result.
Finally, while viewing the video, the script will click to the playing time bar for 2 times.

You are able to modify this script to fit your need, as well as make it more flexible, more real. Or you can also as help from us to create your own script.

https://youtu.be/mT6NSk1M3E4

Code: Select all

//Wait for page load
await Delay(1000);
while(await IsLoading()) await Delay(1000);

//typing a random keyword and hit enter (13 is key code of Enter key)
var randomKeyword = RandomArray(["bypass captcha 9hits", "google search 9hits"]);
await Delay(1000);
Typing(randomKeyword);
await Delay(1000);
SendKeyPress(13);

//delay for a while when we just press Enter.
await Delay(5000);

//check for our target if found or not. I would like to click to any video has title contain 9Hits
var myTarget = GenerateXpath("a", "text", "%9Hit%");
var found = false;

var pageCount = 0;
while(!found)
{
    found = await GetAttribute(myTarget, "href");
    
    //if found the target, do click it
    if(found){
        ClickByXpath(myTarget);
        await Delay(5000); //wait for the video load
        
        //click to the time playing process
        await Delay(Random(5000, 10000));
        ClickByClass("ytp-load-progress");
        
        //click to the time playing process one more time
        await Delay(Random(5000, 10000));
        ClickByClass("ytp-load-progress");
        
        // do more interaction....
        //.....
        //----------
        
        break;
    }
    
    //if not found, scroll down to laod more result, and check again
    SendMouseWheel(0, -10000);
    await Delay(3000);
    
    //suppose we only scroll down for 5 times.
    if(pageCount > 5) break;
    pageCount++;
}

BarryGreep
Posts: 10
Joined: Sat Jun 29, 2019 2:39 pm
Location: United Kingdom
Contact:

Searching video on Youtube

Post by BarryGreep » Fri Jul 05, 2019 9:35 am

I have been searching for a video of a cammed 4.0 mustang, ranger, explorer, i am not too consirened over which vehicle it is, i just am looking to a. see what a cammed 4.0 sohc sounds like, and B. see how well it runs. If anyone has any good videos and is kind enough to post them here it would be greatly appriciated.

Wissmo
Posts: 1
Joined: Thu Aug 29, 2019 4:44 am

Re: Searching video on Youtube !

Post by Wissmo » Wed Oct 02, 2019 4:55 pm

The code from above has not worked for me. Just made a few changes

Code: Select all

//waits for page to load
await Delay(1000);
while(await IsLoading()) await Delay(1000);

//types the keyword and hit enter (13 is key code of Enter key)
await ClickByXpath(GenerateXpath("input", "type", "text"));
var randomKeyword = RandomArray(["keyword 1", "keyword 2"]);
await Delay(1000);
Typing(randomKeyword);
await Delay(2000);
SendKeyPress(13);

//just waits 5 seconds after search
await Delay(5000);

//checks for the target if its there. If yes, its clicks on any video that contains your keyword in the title
var myTarget = GenerateXpath("a", "title", "%keyword%"); //change "keyword" to your own keyword
var found = false;

var pageCount = 0;
while(!found)
{
    found = await GetAttribute(myTarget, "href");
    
    //if found the target, do click it
    if(found){
        ClickByXpath(myTarget);
        await Delay(5000); //wait for the video to load
        
        //clicks randomly in the progress bar
        await Delay(Random(5000, 10000));
        ClickByClass("ytp-load-progress");
        
        //clicks randomly in the progress bar one more time
        await Delay(Random(5000, 10000));
        ClickByClass("ytp-load-progress");
        
        //opens the show more in the discription
        await Delay(Random(5000, 10000));
        ClickByClass("more-button style-scope ytd-video-secondary-info-renderer");
        
        //scrolls down to the comments
        await Delay(Random(2000, 5000));
        SendMouseWheel(0, -10000);
        
        //scrolls down to the comments
        await Delay(Random(2000, 5000));
        SendMouseWheel(0, -10000);
        
        //scrolls back up to the video
        await Delay(Random(2000, 5000));
        SendMouseWheel(0, 20000);
        
        break;
    }
    
    //if not found, scrolls down to laod more result, and check again
    SendMouseWheel(0, -10000);
    await Delay(3000);
    
    //only scrolls down for 5 times.
    if(pageCount > 5) break;
    pageCount++;
}

Post Reply