在PHP中,你可以使用卷曲在相同的URL,表单动作后表单的数据:https://salute.regione.veneto.it/servizi/situazione-nei-pronto-soccorso?p_p_id=PRONTOSOCCORSO_WAR_portalprontosoccorso_INSTANCE_o0QZ&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-3&p_p_col_count=1
,并取回HTML页面。
php脚本,激发德https://davidwalsh.name/curl-post的实例(你必须安装卷曲得到工作本示例):
<?php
$url = 'https://salute.regione.veneto.it/servizi/situazione-nei-pronto-soccorso?p_p_id=PRONTOSOCCORSO_WAR_portalprontosoccorso_INSTANCE_o0QZ&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-3&p_p_col_count=1';
$fields = array(
'ulss' => '101',
'provincia' => 'BL',
'nomPS' => '',
'rossoInAttesa' => '',
'gialloInAttesa' => '',
'verdeInAttesa' => '',
'biancoInAttesa' => ''
);
//url-ify the data for the POST
$fields_string = "";
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
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_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute post
$result = curl_exec($ch);
file_put_contents('result_page.html', $result);
//close connection
curl_close($ch);
你已经就如何做到这一点的样品?我在PHP中是一个新手...谢谢! (无论如何,你的第一个使用PhantomJS的建议可能会很有趣......) – Cesare
如果你使用JS,phantomJS可以很好的做页面自动化,但你的问题是关于PHP的,所以;) – nicolastorre
可能是一个有趣的替代方案... 。感谢代码示例 – Cesare