我正在用PHP编写过去3年的数据抓取脚本。在
这是一个简单的PHP脚本$url = 'https://appext20.dos.ny.gov/corp_public/CORPSEARCH.SELECT_ENTITY';
$fields = array(
'p_entity_name' => urlencode('AAA'),
'p_name_type' => urlencode('A'),
'p_search_type' => urlencode('BEGINS')
);
//url-ify the data for the POST
foreach ($fields as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
$fields_string = rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
print curl_error($ch) . '
';
print curl_getinfo($ch, CURLINFO_HTTP_CODE) . '
';
print $result;
只有当CURLOPT_SSL_VERIFYPEER是false时,它才能正常工作。如果我们启用CURLOPT_SSL_VERIFYPEER或使用http而不是https,则返回空响应。在
但是,我必须用pythonscrapy做这个项目,这里是Scrapy中的相同代码。在
^{pr2}$
它返回空响应。需要禁用SSL验证。在
请原谅我对Python Scrapy缺乏了解,我已经搜索了很多,但没有找到任何解决方案。在