What PHP command would peek into a page and record its HTML code (source)? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this questionWould you, please, tell me what command (or a combination of those) in PHP would check a web-page by its URL and possibly download its code (HTML) into a variable? Well, I was suggested to use Goggle App Engines for this here, but I am also quite q curious about how much of that task can PHP perform.
$f = file_get_contents('http://www.google.com');
http://php.net/file_get_contents
Hello
First Visit this webpage file-get-contents.
If you think the above is to complex use a library
PHP Simple HTML DOM Parser download here PHP Simple HTML DOM Parser
And Finaly here is the code
<?php
include_once 'simple_html_parser.php';
$html = file_get_html('http://www.google.com/');
// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
?>
You could use curl. Here is a tutorial
精彩评论