0

I'm new to php and I'm trying to download a webpage text(no need to seperate the data with elements or things like that). Could someone Give a simplized php program (using curl) so I can Get to know it more like the syntax things . for example could someone download a simple site text?

3
Contributors
5
Replies
12
Views
4 Years
Discussion Span
Last Post by pritaeas
0

Here there's the example of PHP manual: http://php.net/manual/en/curl.examples-basic.php

<?php

$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

but you can do the same with file_get_contents() and file_put_contents():

$url = 'http://www.example.com/';
$page = file_get_contents($page);
file_put_contents('example_homepage.txt',$page);
0

Does this get text that is brought to the page with java script ? and does it save them in file in the top file ?

1

Does this get text that is brought to the page with java script ?

No. It only returns the initial HTML source.

0

does curl have the ability to get the data (text) that is written by javascript ?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.