mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 12:14:36 +00:00
Add setURL examples
This commit is contained in:
@@ -5,7 +5,7 @@ use \Curl\Curl;
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->download('https://php.net/images/logos/php-med-trans.png', function($instance, $tmpfile) {
|
||||
$save_to_path = '/tmp/_' . basename($instance->url);
|
||||
$save_to_path = '/tmp/' . basename($instance->url);
|
||||
$fh = fopen($save_to_path, 'wb');
|
||||
stream_copy_to_stream($tmpfile, $fh);
|
||||
fclose($fh);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require '../src/Curl/Curl.php';
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
// Retrieve first N pages of search results.
|
||||
$pages = 10;
|
||||
$q = 'coffee';
|
||||
|
||||
$curl = new Curl('https://www.example.com/search');
|
||||
|
||||
for ($i = 1; $i <= $pages; $i++) {
|
||||
// https://www.example.com/search?q=coffee&page=N
|
||||
$curl->get(array(
|
||||
'q' => $q,
|
||||
'page' => $i,
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require '../src/Curl/Curl.php';
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
// Retrieve first N pages of search results.
|
||||
$pages = 10;
|
||||
$q = 'coffee';
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->setURL('https://www.example.com/search');
|
||||
|
||||
for ($i = 1; $i <= $pages; $i++) {
|
||||
// https://www.example.com/search?q=coffee&page=N
|
||||
$curl->get(array(
|
||||
'q' => $q,
|
||||
'page' => $i,
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user