httpclient爬虫怎么获取cookies
展开全部
需要源码入下。
private function parseCookieLine($line)
{
$now = time();
$cookie = array('name' => '', 'value' => '', 'expires' => null, 'path' => '/');
$cookie['domain'] = $this->req->getHeader('host');
$tmpa = explode(';', substr($line, 12));
foreach ($tmpa as $tmp)
{
if (($pos = strpos($tmp, '=')) === false)
continue;
$k = trim(substr($tmp, 0, $pos));
$v = trim(substr($tmp, $pos + 1));
if ($cookie['name'] === '')
{
$cookie['name'] = $k;
$cookie['亏枣袭value'] = $v;
}
else
{
$k = strtolower($k);
if ($k === 'expires')
{
$cookie[$k] = strtotime($v);
if ($cookie[$k] < $now)
$cookie['value'] = '';
}
else if ($k === 'domain')
{
$pos = strpos($cookie['domain'], $v);
if ($pos === 0
|| substr($cookie['销兄domain'], $pos, 1) === '.'
|| substr($cookie['岩型domain'], $pos + 1, 1) === '.')
{
$cookie[$k] = $v;
}
}
else if (isset($cookie[$k]))
{
$cookie[$k] = $v;
}
}
}
if ($cookie['name'] !== '')
return $cookie;
return false;
}
private function parseCookieLine($line)
{
$now = time();
$cookie = array('name' => '', 'value' => '', 'expires' => null, 'path' => '/');
$cookie['domain'] = $this->req->getHeader('host');
$tmpa = explode(';', substr($line, 12));
foreach ($tmpa as $tmp)
{
if (($pos = strpos($tmp, '=')) === false)
continue;
$k = trim(substr($tmp, 0, $pos));
$v = trim(substr($tmp, $pos + 1));
if ($cookie['name'] === '')
{
$cookie['name'] = $k;
$cookie['亏枣袭value'] = $v;
}
else
{
$k = strtolower($k);
if ($k === 'expires')
{
$cookie[$k] = strtotime($v);
if ($cookie[$k] < $now)
$cookie['value'] = '';
}
else if ($k === 'domain')
{
$pos = strpos($cookie['domain'], $v);
if ($pos === 0
|| substr($cookie['销兄domain'], $pos, 1) === '.'
|| substr($cookie['岩型domain'], $pos + 1, 1) === '.')
{
$cookie[$k] = $v;
}
}
else if (isset($cookie[$k]))
{
$cookie[$k] = $v;
}
}
}
if ($cookie['name'] !== '')
return $cookie;
return false;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家提供动态代理服务器服务的企业,旨在帮助用户更好地管理网络访问和安全。以下是一些关于StormProxies的IP动态代理服务的特点:1. 高匿名性:StormProxies的动态代理服务器具有高匿名性,可以有效...
点击进入详情页
本回答由Storm代理提供
2014-02-11
展开全部
把header里面的cookie取下,下次递交前,设置cookie
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询