You can use a Regular Expression to capture all this data. This way you can easily filter the content.
The simplest way to capture these values with the PHP
, is to use the function preg_match_all.
For that you would need to define the regex (Expressão Regular)
to the algorithm of the PHP
, search and return values.
Capturing the API proxies
proxies.php:
<?php
// Aqui seria a requisição para capturar a lista de proxy
$proxies = file_get_contents("proxies.html");
// Expressão Regular
$regex = <<<REGEX
[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}:[\d]{2,5}
REGEX;
// Aqui o código filtrar os valores da variável $proxies, conforme o regex e depois irá retornar os valores para a variável $results
preg_match_all("/{$regex}/", $proxies, $results);
// Imprimi na tela
echo implode("\n", reset($results));
This regex is very simple, but I recommend reading the article How to Find or Validate an IP Address. In it you will learn how to capture only valid IP’s.
If interested, you can access the Regex101 to know how the above regex works. Step by step it.
Updating the proxies every minute.
index.html
Here will be a very basic code.
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<textarea id="results"></textarea>
<script src="myscript.js"></script>
</body>
</html>
myscript.js
To execute the code every "x" time, use the function setInterval. To do this just pass the function and time (in milliseconds)
var results = document.querySelector("#results");
setInterval(function() {
var req = new XMLHttpRequest();
req.addEventListener("loadend", function(request) {
results.value += request.target.response+"\n";
});
req.open("GET", "/index2.php");
req.send();
}, 60 * 1000);
Add the proxy list, it will be easier. No need to post the IP’s/ proxy address, use "X" to hide them.
– Valdeir Psr