Im trying to get the url of the apple touch icon image using php but i am not successful. I found this on S.O. using this but this doesnt work either:
$html = file_get_html($url);
$img = $html->find('img[rel=apple-touch-icon]');
echo $img->href;
Any ideas on how I could accomplish this? I was thinking I could use file_get_contents() but I am not sure how to approach that.
Related
Hi,
I want to get the screenshot of several pages and display them on my website. As of now, I am using the method below:
<?php
$site = $screenurl;
$image = file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$site&screenshot=true");
$image = json_decode($image, true);
$image = $image['screenshot']['data'];
$image = str_replace(array('_','-'),array('/','+'),$image);
echo "<img src=\"data:image/jpeg;base64,".$image."\" alt=\"\">";
?>
but with 10 or more images per page, this method takes FOREVER to load them all or it wont even load them at all because it times out. I would like to know a more effective, optimized and faster way to do this.
Thank you.
Not sure if this is exactly what you're looking for, but PHP's built-in (PHP >= 5.2.2) imagegrabscreen function is capable of returning an image resource containing a screenshot of the whole screen. It is sort of picky, though, from what I understand (never used it myself), requiring it to be run on a Windows system and "allow Apache service to interact with the desktop". These documentation pages could be helpful:
imagegrabscreen Function
imagegrabwindow Function
Wow, i hope i have written the title in a correct way, because i really have no idea how this is called.
Let me explain what i am looking for.
I have a simple application. And it contains the following:
- Frontpage (salespage)
- Admin area
- Member area
- Database to provide the app of data
I have hosted the basics of this application on a server, let's call it 'www.the.app'. And i have written it in PHP using Laravel.
Now i want to use the functions of the app, which is hosted on www.the.app and use the functions like the admin area, member area, the frontpage and create my own database on 'www.awesome.app'.
What would be the best way to make such a thing happen?
I am not looking for direct solutions. I am just looking for information to point me in the right direction to be able to make the above reality. Anything would be apreciated, like information, a name i can search on, what ever is related to this.
And if there is any more information needed, let me know please :)
Here is exactly how you can do it :
1) To Auto Login To The Site :
Note : As you will need to probably get data from login based site so you can auto login to the site through using CURL while using User Credentials with it.
To Learn How To Login Through CURL.Take A Look At :
Using PHP & Curl to login to my websites form
2) Extracting Data After Logging In Through CURL :
Note : After logging to the site now you will need to use PHP DOM to extract data from the site.So you can extract data something like this way by using PHP Simple HTML DOM Parser Library.
PHP Simple HTML DOM Parser :
LINK : http://simplehtmldom.sourceforge.net/
Sample Code For Downloading All Images From A Link :
Note : Following code will download all the images present at the URL given in the code.
<?php
// Make sure to include the library php file
include('simple_html_dom.php');
//URL To Download Images From
$url = "http://www.facebook.com/"
// Create DOM from URL or file
$html = file_get_html($url);
// Find all images
$i=1;
foreach($html->find('img') as $element) {
$url = $element->src;
$img = "/my_folder/image_".$i.".png";
file_put_contents($img, file_get_contents($url));
$i++;
}
?>
i need some help as i am completely novice with php..
I have made a simple script to get an XML tracklist (from an API), then decode what i need and make a ul list with the tracks..
I also need to pull some artist images from a last.fm php script i found recently..
The scripts api is using http adress to get the artist and then bring up the images i found it here https://gist.github.com/iwek/5109952 and the syntax of request is : http://example.com/lastfm.php?artist=Adele
My php code for tracklist is :
foreach ($mysongs as $item):
$x = explode(" - ",$item->track);
$artist = $x[0];
$title = $x[1];
echo "<ul>$artist
$song</ul>\n";
endforeach;
Now i need to put inside the foreach the php code to generate the api call url and also include the image that this script outputs.. I am really stuck here guy's !
If anyone has any idea please do tell !
PS: keep in mind that i am really novice with php..
Thank you for your answers
$url = "http://www.example.com/lasfm.php";
$artist="Adele";
echo "$url?artist=$artist";
I had a big PHP script written out to scrape images from this site: "http://www.mcso.us/paid/", but when it didn't work I butchered my code to simply echo the whole page.
I found that the table with the image links I want doesn't show up. I believe it's because the remote site uses ASP to generate the table. Is there a way around this? Am I wrong? Please help.
<?php
include("simple_html_dom.php");
set_time_limit(0);
$baseURL = "http://www.mcso.us/paid/";
$html = file_get_html($baseURL);
echo $html;
?>
There's no obvious reason why them using ASP would cause this, have you tried navigating the page with JavaScript turned off? It's a more likely scenario that the tables are generated through JS.
Do note that the search results are retrieved through ajax ( page http://www.mcso.us/paid/default.aspx ) by making a POST request, you can use cURL http://php.net/manual/en/book.curl.php , use chrome right-click-->inspect element---> network and make a search you will see all the info there (post variables etc ...)
I’m trying to display a swf from another site into mine.
I’ve got permission from the other side to do so I’m just having problems figuring it all out.
I’d like to display just the swf not the entire page that swf is on.
I’ve tried this – but it only seems to work with content and I haven’t had any luck getting the swf to appear.
<?php $conts = file_get_contents('http://www.test.com/');
$pattern = '~<div.*id="content".*>(.*)</div>~iUs';
preg_match($pattern, $conts, $matches);
array_shift($matches);
echo $matches[0]; ?>
How can a go about doing this.
Thanks!
I'm not sure I understand your question :-? but I believe you could use something like this. Create an embed object on your site and in it's src point it to the external swf. Will that work ?
Well, you can't just grab the div that have the SWF, you need to grab the URL of the SWF. For instance, instead of doing this $pattern = '~<div.*id="content".*>(.*)</div>~iUs'; try something like $pattern = '~<embed.*src=".+".*>.*</embed>~iUs';
That way you'll getting the src of the SWF, along with the embed tag, which you can use in your site.