SandPrince
Registered
може ли да се напише търсачка която да търси в youtube???
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
да може, и то не трудно. с curl според мен ще стане наи лесно.SandPrince каза:може ли да се напише търсачка която да търси в youtube???
mute каза:да може, и то не трудно. с curl според мен ще стане наи лесно.SandPrince каза:може ли да се напише търсачка която да търси в youtube???
mute каза:добре ето по лесен вариант
http://youtube.com/results?search_query=duma&search=Search
$content=file_get_contents('http://youtube.com/results?search_query='.$_GET['duma'].'&search=Search');
$_GET['duma'] e въведената дума от твоята търсачка
с file_get_contents ще вземеш съдържанието на страницата с резултатите от теб се изка да я парснеш
<?php
echo "<form method=post action=search.php>";
echo "Enter string to search:<br>";
echo "<input type=text name=string><p>";
echo "<input type=submit value=Search></form>";
?>
<?php
$string = $_POST['string'];
echo "<frameset cols=100 border=1><frame src='http://www.youtube.com/results?search_query=$string&search_type=&aq=f' scrolling=auto target=_self noresize=noresize></frameset>";
?>
То ако ще е с фрейм, направо youtube да си отвори човекBummer каза:Ето, какво написах
index.php
search.phpКод:<?php echo "<form method=post action=search.php>"; echo "Enter string to search:<br>"; echo "<input type=text name=string><p>"; echo "<input type=submit value=Search></form>"; ?>
Демо: http://l337z0n3.com/vbox/Код:<?php $string = $_POST['string']; echo "<frameset cols=100 border=1><frame src='http://www.youtube.com/results?search_query=$string&search_type=&aq=f' scrolling=auto target=_self noresize=noresize></frameset>"; ?>
<form action="" method="post">
Търси: <input type="text" name="search" size="30">
<input type="submit" name="submit" value="Търси">
</form>
<?php
$search = $_POST['search'];
$search = str_replace(" ","+",$search);
$contents = file_get_contents("http://www.youtube.com/results?search_query=".$search."&search_type=&aq=f");
if (eregi("<strong>0 - 0</strong>",$contents)) {
echo "Търсенето ви не върна резултати :)";
} else {
preg_match_all('/<div class="vlcontainer">(.*)/',$contents,$matches);
foreach($matches[0] as $value) {
echo $value;
}
$raz = explode('<div class="pagingDiv">',$contents);
$raz = explode('</div>',$raz[1]);
echo $raz[0];
}
?>
<?php
if (isset($_GET['video'])) {
?>
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/<?=$_GET['video']?>&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/<?=$_GET['video']?>&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>
<?php
} else {
?>
<form action="?" method="post">
Търси: <input type="text" name="search" size="30">
<input type="submit" name="submit" value="Търси">
</form>
<?php
if (isset($_GET['search'])) {
$search = $_GET['search'];
} else {
$search = $_POST['search'];
}
$search = str_replace(" ","+",$search);
if (isset($_GET['page']) && $_GET['page'] > 0 && is_numeric($_GET['page'])) {
$contents = file_get_contents("http://www.youtube.com/results?search_query=".$search."&page=".$_GET['page']);
} else {
$contents = file_get_contents("http://www.youtube.com/results?search_query=".$search."&search_type=&aq=f");
}
if (eregi("<strong>0 - 0</strong>",$contents)) {
echo "Търсенето ви не върна резултати :)";
} else {
preg_match_all('/<div class="vlcontainer">(.*)/',$contents,$matches);
$matches[0] = array_map("htmlspecialchars",$matches[0]);
#print_r($matches[0]);
foreach($matches[0] as $value) {
$link4e = explode('watch?v=',$value);
$link4e = explode('" >',$link4e[1]);
$img = explode('<img',$value);
$img_end = explode('>',$img[1]);
$img = explode('src="',$img_end[0]);
$img = explode('"',$img[1]);
$title = explode('title="',$img_end[0]);
$title = explode('"',$title[1]);
echo '<a href="?video='.$link4e[0].'"><img src="'.$img[0].'"><br />'.$title[0].'</a><br /><br />';
}
$raz = explode('<div class="pagingDiv">',$contents);
$raz = explode('</div>',$raz[1]);
$raz = str_replace('/results?search_query='.$search,'?search='.$search,$raz[0]);
echo str_replace('&page=','&page=',$raz);
}
}
?>
<?php
if (isset($_GET['video'])) {
?>
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/<?=$_GET['video']?>&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/<?=$_GET['video']?>&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>
<?php
} else {
?>
<form action="?" method="post">
Търси: <input type="text" name="search" size="30">
<input type="submit" name="submit" value="Търси">
</form>
<?php
if (isset($_GET['search'])) {
$search = $_GET['search'];
} else {
$search = $_POST['search'];
}
$search = str_replace(" ","+",$search);
if (isset($_GET['page']) && $_GET['page'] > 0 && is_numeric($_GET['page'])) {
$contents = file_get_contents("http://www.youtube.com/results?search_query=".$search."&page=".$_GET['page']);
} else {
$contents = file_get_contents("http://www.youtube.com/results?search_query=".$search."&search_type=&aq=f");
}
if (eregi("<strong>0 - 0</strong>",$contents)) {
echo "Търсенето ви не върна резултати :)";
} else {
preg_match_all('/<div class="vlcontainer">(.*)/',$contents,$matches);
$matches[0] = array_map("htmlspecialchars",$matches[0]);
#print_r($matches[0]);
foreach($matches[0] as $value) {
$link4e = explode('watch?v=',$value);
$link4e = explode('" >',$link4e[1]);
$img = explode('<img',$value);
$img_end = explode('>',$img[1]);
$img = explode('src="',$img_end[0]);
$img = explode('"',$img[1]);
$title = explode('title="',$img_end[0]);
$title = explode('"',$title[1]);
echo '<a href="http://youtube.com/watch?v='.$link4e[0].'"><img src="'.$img[0].'"><br />'.$title[0].'</a><br /><br />';
}
$raz = explode('<div class="pagingDiv">',$contents);
$raz = explode('</div>',$raz[1]);
$raz = str_replace('/results?search_query='.$search,'?search='.$search,$raz[0]);
echo str_replace('&page=','&page=',$raz);
}
}
?>