-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtubeget.php
51 lines (38 loc) · 1.15 KB
/
youtubeget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
require_once "simple_html_dom.php";
require_once 'connection.php';
require_once "functions.php";
for ($i = 0; $i < 50; $i++) {
//echo(file_get_html('www.google.com'));
$string1 = "unity3d"; // Number in database
$string2 = "programming";
$html = file_get_html('http://www.youtube.com/results?search_query='.$string1.'+'.$string2.'&page=' . $i);
foreach ($html->find('li[class=yt-grid-box]') as $element) {
$s = explode('"', $element);
for ($q = 0; $q < count($s); $q++) {
if (strlen(strstr($s[$q], "watch?v=")) > 0) {
$st =substr($s[$q], 0,20);
if(ex_query1RowAns("Select 1 from ProcessVideos where url =\"".$st."\"")!=1)
{
ex_query("INSERT INTO `TMSprdDB`.`ProcessVideos` (
`url` ,
`string1`,
`string2`,
`type` ,
`processed`
)
VALUES ('".$st."','$string1','$string2','YouTube','No')");
echo "\nInserted video ".$st."\n <br>";
}
else {
echo "Already Inserted \n <br>";
}
//$rest = substr("abcdef", -2); // returns "ef"
}
}
}
// var_dump($html->find('div[class=yt-lockup-content]'));
// echo $ret;
}
//i got every page now i just have crawl all of them and get links for the videos
?>