gpt4 book ai didi

PHP SSL curl : object moved error

转载 作者:可可西里 更新时间:2023-10-31 23:07:51 25 4
gpt4 key购买 nike

我正在开发一个 php 脚本来抓取该网站并将数据通过电子邮件发送给我。它似乎正确登录,因为当脚本运行时,它似乎重定向并给我一条消息说对象移动到这里并且这里链接到 default.aspx 页面,这正是我手动登录时发生的情况。

下面是我的脚本:

<?php
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";

// INIT CURL
$ch = curl_init();

//init curl
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'https://access.manager.com/Login.aspx');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

// Set your login and password for authentication
curl_setopt($ch, CURLOPT_USERPWD, 'testu:passwd');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);


// This is occassionally required to stop CURL from verifying the peer's certificate.
// CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if
// CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2 - check the existence of a
// common name and also verify that it matches the hostname provided)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// Optional: Return the result instead of printing it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'Username=testu&Password=passwd');

# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
echo $store;
// CLOSE CURL
curl_close ($ch);

?>

任何想法可能会阻止页面正确输出页面?我猜它没有正确重定向。

提前致谢

最佳答案

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

将其更改为 1。此外,在 CURLOPT_SSL_VERIFYPEER 之后设置:

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

关于PHP SSL curl : object moved error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1279340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com