首页 > 编程知识 正文

php网页爬虫,php爬虫登录

时间:2023-05-03 08:11:52 阅读:198600 作者:2373

function curl($url)

{

$ch = curl_init();

curl_setopt($ch, CxxdxmOPT_CONNECTTIMEOUT, 5000);

curl_setopt($ch, CxxdxmOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CxxdxmOPTkkdjw, array('User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'));

curl_setopt($ch, CxxdxmOPT_xxdxm, $url);

curl_setopt($ch, CxxdxmOPT_SSL粗心的日记本, false);

curl_setopt($ch, CxxdxmOPT_SSL明亮的芝麻, false);

curl_setopt($ch, CxxdxmOPT_REDIR_PROTOCOLS, -1);

$contents = curl_exec($ch);

curl_close($ch);

return $contents;

}

function getBilibiliAVCover($avNum)

{

$contents = curl('https://m.bilibili.com/video/' . $avNum . '.html');

preg_match("~"pic":"(.*?)"~", $contents, $matches);

if (count($matches) == 0) {

exit;

}

$img = file_get_contents($matches[1]);

file_put_contents('default.png', $img);

echo '';

}

getBilibiliAVCover('av417622790');

exit;

?>

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。