Saturday 15 September 2012

file get contents - How to bypass Target Machine refusing connection on external website - PHP file_get_contents -



file get contents - How to bypass Target Machine refusing connection on external website - PHP file_get_contents -

<?php $f = file_get_contents("http://www.example.com"); echo htmlspecialchars($f); ?>

will output

<!doctype html> <html> <head> <title>example domain</title> <meta charset="utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style type="text/css"> body { background-color: #f0f0f2; margin: 0; padding: 0; font-family: "open sans", "helvetica neue", helvetica, arial, sans-serif; } div { width: 600px; margin: 5em auto; padding: 50px; background-color: #fff; border-radius: 1em; } a:link, a:visited { color: #38488f; text-decoration: none; } @media (max-width: 700px) { body { background-color: #fff; } div { width: auto; margin: 0 auto; border-radius: 0; padding: 1em; } } </style> </head> <body> <div> <h1>example domain</h1> <p>this domain established used illustrative examples in documents. may utilize domain in examples without prior coordination or asking permission.</p> <p><a href="http://www.iana.org/domains/example">more information...</a></p> </div> </body> </html>

however if seek like:

<?php $f = file_get_contents("http://www.yahoo.com"); echo htmlspecialchars($f); ?>

i receive error

warning: file_get_contents(http://www.yahoo.com): failed open stream: no connection made because target machine actively refused it. in c:\wamp\www\popup.php on line 12

is there anyway work around this? html elements within yahoo page struggling open yahoo page in manner

this works on machine:

$page = fopen( "http://www.yahoo.com", "r" ); while ( ! feof( $page )) print fgets( $page, 1024 ); fclose( $page );

php file-get-contents

No comments:

Post a Comment