cURL和JavaScript的提交按钮->ajax
cURL and submit button of JavaScript -> ajax?
我正在使用cURL尝试登录此网站https://myportal.vtc.edu.hk/wps/portal/,但我发现有一个javascript函数
<"onclick="GoLogin(); return false;">
以控制登录访问。
所以我无法连接到这个网站,这是我下面的代码,
<?php
$username = 'userid';
$password = 'password';
$loginUrl = 'https://myportal.vtc.edu.hk/wps/portal';`
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'userid='.$username.'&password='.$password );
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'https://myportal.vtc.edu.hk/wps/myportal/!ut/p/c4/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hTC39DAxNz98CwMEtTA08f50DjQEdzIwMDI_2CbEdFABEW-jM!/');
$content = curl_exec($ch);
curl_close($ch);
?>
这是GoLogin()函数:
$.ajax({
url: loginForm.attr('action'),
cache: false,
async: false,
data: params,
type: "POST",
complete: function(jqXHR, textStatus) {
if (jqXHR.status == 200) {
// login successfull
window.location = '/wps/myportal';
} else if (jqXHR.status == 399) {
// login successfull
window.location = jqXHR.responseText;
}
我如何登录这个网站,请帮我。
这样你就无法连接,因为通过curl你无法执行javascript。
对于上述要求,您应该使用http://phantomjs.org/。
它的php库也可用。
https://github.com/jonnnnyw/php-phantomjs
或者你可以看看http://slimerjs.org/.
相关文章:
- Ajax文件加载和<输入>文件加载
- JS对象->来自jquery ajax的JSON提交->php迭代
- 使用<a>onclick将ajax内容打开到fancybox中
- 使用PrimeFaces<p: ajax>,只在更改字段的键击时在inputText中启动Ajax
- "显示更多“<h: 命令按钮>使用ajax
- ajax调用:响应<->数据类型
- 如何编写插入新<a>使用onclick AJAX调用
- 调用.ajax方法得到未定义的json结果,返回json格式列表<字符串>
- F5负载平衡器附加<脚本>到JSON Ajax响应
- 在<李>来自ajax
- 如何为<a>ajax响应中的元素
- 为什么PHP对AJAX的响应包含<脚本>aBunchOfJavascript此处</脚本>
- Struts Javascript AJAX成功页面更新<脚本>援引
- 无法将ajax:success绑定到使用form_for..创建的表单:remote=>是的
- Jquery数据表功能在<f: ajax>
- 捕获<的img加载错误;img>页面加载后创建的标签(例如通过AJAX)
- cURL和JavaScript的提交按钮->ajax
- 替换/编码<并且>在提交之前使用jquery/ajax
- 隐藏<td>AJAX刷新后从表中删除
- 从HTML表单传递变量->ajax加载()