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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.