curl从外部网站获取价值需要用户​​名和密码 [英] curl get value from outside website need username and password

查看:85
本文介绍了curl从外部网站获取价值需要用户​​名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在网站外获取一些需要用户名和密码的价值表格。

通常我需要先登录页面(https://xxx.xxx.xxx/HomeAccess),然后转到https://xxx.xxx.xxx/xxx.aspx。但如果没有登录只是转到页面xxx.aspx,我会得到错误由于发生内部服务器错误,页面无法显示。;



in PHP我正在尝试使用此代码

I am trying to get some value form outside website which need username and password.
normally I need go to login page first(https://xxx.xxx.xxx/HomeAccess), then go to https://xxx.xxx.xxx/xxx.aspx. But if without login just go to the page xxx.aspx, I will get errror "The page cannot be displayed because an internal server error has occurred.";

in PHP I'm trying use this code

<?php

$ch = curl_init();
$url = 'https://xxx.xxx.xxx/xxx.aspx';
$username ='uuuuu';
$password ='ppppp';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

print $output;

?>





我有空白页。



有什么想法吗?谢谢



I got blank page.

Any idea? thanks

推荐答案

ch = curl_init();
ch = curl_init();


url ='https://xxx.xxx.xxx/xxx。 aspx';
url = 'https://xxx.xxx.xxx/xxx.aspx';


username ='uuuuu';
username ='uuuuu';


这篇关于curl从外部网站获取价值需要用户​​名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆