You can use Regular Expression to capture all of this data. This way you can easily filter content.
The simplest way to capture these values with PHP
is to use the preg_match_all .
For this you would need to set the regex (Expressão Regular)
to the PHP
algorithm itself, do the searches and return the values.
Capturing 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 you are interested, you can visit the Regex101 site to find out how regex above works. His step by step.
Updating the proxies every min.
index.html
Here is 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 run the code every "x" time, use the setInterval . To do this simply 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);