开发者

What PHP command would peek into a page and record its HTML code (source)? [closed]

Closed开发者_如何转开发. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

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 question

Would 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜