dou7466 2015-03-21 20:17 采纳率: 0%
浏览 41

使用php curl在https网站填写表单登录

Hey try to fill the login form of this page https://nomade.pericles.fr to acces to this one https://nomade.pericles.fr/#/accueil with this code but no work I stay stuck on login page with 404 error if someone have idea ?

<?php 

$url = 'https://nomade.pericles.fr/#/accueil'; 
$timeout = 10; 
$agent            = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36";
$cookie_file_path = "/tmp/cookies.txt";

$ch = curl_init($url); 

curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 

if (preg_match('`^https://`i', $url)) 
{ 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
} 

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

// Utilisation de la méthode POST 
curl_setopt($ch, CURLOPT_POST, true); 

// Définition des champs et valeurs à envoyer 
curl_setopt($ch, CURLOPT_POSTFIELDS, array( 
'user_id' => '********', 
'user_pwd' => '********'
)); 
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); 
$page_content = curl_exec($ch); 

curl_close($ch); 

echo $page_content; 

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度