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?

Recommended Answers

All 5 Replies

Here there's the example of PHP manual: http://php.net/manual/en/curl.examples-basic.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);


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

$url = 'http://www.example.com/';
$page = file_get_contents($page);

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

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

No. It only returns the initial HTML source.

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


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.