TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Stalin Antony Huallullo Cirineo
NA
99
6.3k
File_get_contents with https, extract images with hotlinking
Aug 11 2017 8:34 PM
Hello, I want to extract images from this web "https://animeflv.net/" and when I get it gives me "Error 1011" because it says that your web has activated "Hotlinking".
Note: The error is only when displaying it, the images are not displayed.
function https($url){
$cookie_file_path = "c:/cookiefile";//o lo que sea
$LOGINURL = $url;
//$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36';
$POSTFIELDS = 'user=usuario&pass=password';//o lo que sea
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
//curl_setopt($ch, CURLOPT_REFERER, $LOGINURL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$page = curl_exec ($ch);
curl_close ($ch);
return $page;
}
$html = https("https://animeflv.net/");
$patron = "'<ul class=\"ListAnimes AX Rows A06 C04 D03\">(.*?)</ul>'si";
preg_match_all($patron, $html, $sujet);
//echo "Numero --> ".count($sujet[1])."<br/>";
//var_dump($sujet);
for ($i=0; $i < count($sujet[0]); $i++) {
$patron_li = "'<li>(.*?)</li>'si";
preg_match_all($patron_li, $sujet[1][0], $li);
for ($li_content=0; $li_content < count($li[1]); $li_content++) {
//echo "----------------------"."<br/>";
$patron_link = "'<a href=\"(.*?)\">'";
$patron_img = "'<img src=\"(.*?)\" alt=\"(.*?)\">'si";
$patron_titulo = "'<h3 class=\"Title\">(.*?)</h3>'si";
preg_match($patron_link, $li[1][$li_content], $link_a);
preg_match($patron_img, $li[1][$li_content], $link_img);
preg_match($patron_titulo, $li[1][$li_content], $link_titulo);
$_Url = "https://animeflv.net";
$link = $link_a[1];
$img = $_Url.$link_img[1];
$img_alt = $link_img[2];
$titulo = $link_titulo[1];
echo '<img src="'.$img.'" alt="'.$img_alt.'" itemprop="image" data-original="'.$img_alt.'"/>';
//$imagedata = file_get_contents($img);
//$base64 = base64_encode($img);
//echo '<img src="data:image/jpg;base64,'.$base64.'" />';
//echo '<a href="'.$img.'" >'.$img.'</a><br/>';
}
//echo "Numero --> ".count($li[1])."<br/>";
}
Reply
Answers (
1
)
How to add Attachments in php mail()
how to save data in database and sent email