Jump to content

[SOLVED] HOW to copy the content of a webpage using PHP?


erasam

Recommended Posts

You can use a function method...

 

<?php fucntion YourFunctionName(){?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

</body>
</html>
<?php } ?> 

 

Put those two php codes at both start and end of your document...

 

then included it as a function, hope this is what you ment.

first tell us how do you want to use the page like the data u get out of the get contents

 

Actually, my boss told me to copy a news (in text format) from a website , then paste it to an email and sent to him. I am wondering if there are any PHP scripts can automate this process.

 

THX

file get contents works this way

it reads and get the page as if its a text now to get the specific data you have to explode it and get the array that you really need sample explode the page by <p> represent the paragraph

 

can you give me sample site to get

i actually dont understand is it chinese???

 

ok do it your self

 

$x=file_get_contents('the site here');

$array=explode('<',$x);//you can put the specific html tag that you think can get the exactdata u need

print_r($array);

//or

print_r(file('location here'));

//now you have everything in array but if you sue this it will cause error when the site you where

//you get the data change the format

//or you use curl

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.