V
V
Vladislav2020-03-13 13:54:55
PHP
Vladislav, 2020-03-13 13:54:55

How to run one script from different IP (Proxy)?

I have a PHP parser that works for about 28 days, if it is the only one that collects everything from one IP.
How can I make it so that I can run the same script from different IPs so that the site from which I collect data is not blocked for too many requests and the script significantly reduces its time to collect data.

For example:
from the 1st ip, the script collects data from 1 to 1000000 users.
from the 2nd ip, the script collects data from 1000000 to 2000000 users, etc.
Specify the range, I know how, the only question is how to run them from different IPs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Bukharev, 2020-03-13
@cr1gger

// запрос на тестовый адрес
$url = 'https://goooooogle.com/my-ip.php';

// ip и порт прокси
$proxy = '100.000.00.01:8080';
// если требуется авторизация на прокси-сервере
//$proxyauth = 'user:password';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// подключение к прокси-серверу
curl_setopt($ch, CURLOPT_PROXY, $proxy);
// если требуется авторизация
// curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
// отправка запроса
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
 
// вывод ответа сервера
// должен вернуть все заголовки и ip с которого 
// было обращение, в данном случае это 100.000.00.01
var_dump($curl_scraped_page);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question