Home >Backend Development >PHP Tutorial >正则表达式 - php问题:代理ip地址如何提取出来

正则表达式 - php问题:代理ip地址如何提取出来

WBOY
WBOYOriginal
2016-06-06 20:49:061972browse

如何用php正则把这个代理服务器网站http://www.ipdizhi.com/的代理ip:端口,全部提取出来?

比如提取出:27.34.142.47:9090、177.69.195.4:3128....

回复内容:

如何用php正则把这个代理服务器网站http://www.ipdizhi.com/的代理ip:端口,全部提取出来?

比如提取出:27.34.142.47:9090、177.69.195.4:3128....

<code class="lang-php">
preg_match_all(
  '/\b\d+\.\d+\.\d+\.\d+\:\d+(?=@)/', 
  file_get_contents('http://www.ipdizhi.com/'), 
  $matches);
$proxy_list = $matches[0];

</code>

PS. 那个网站底部有个"代理ip列表txt文件下载"的链接,它本身都帮你提取好了的。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn