提交数据,获取所有t.cn短域名网址
file_get_contents 方式
<?php
function Post($url, $post = null) {
if (is_array($post)) {
ksort($post);
$content = http_build_query($post);
$content_length = strlen($content);
$options = array(
'http' => array(
'method' => 'POST',
'header' =>
"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: $content_length\r\n",
'content' => $content
)
);
return file_get_contents($url, false, stream_context_create($options));
}
}
$data = array
(
'url' => 'https://www.waqiang.com/index.php/url/shorten',
'submit' => 'submit',
);
$response = Post('https://www.waqiang.com/index.php/url/shorten', $data);
$reg = '#[\'"](http:(//|\/\/)t\.cn((/|\/)([^\'"/]+)(/|\/)?|(/|\/)))[\'"]#';
preg_match_all($reg, $response, $match);
var_dump($match);
file_get_contents 方式
&