Home >Backend Development >PHP Tutorial >php用账号密码模拟登陆

php用账号密码模拟登陆

WBOY
WBOYOriginal
2016-06-23 13:47:31952browse

http://112.78.104.13


账号:zm1000,密码a123456,我想用php模拟登陆,但是总是不行,是不是提交方式不对?求大神解答!

或者提取出cookie来也行,但是好像又不支持cookie


回复讨论(解决方案)

1、http://112.78.104.13 是框架页。含有公共变量和函数
2、含登录框的框架是 http://112.78.104.13/app/member
3、表单目标页是 http://112.78.104.13/app/member/login.php
4、登录后返回

<script>top.uid = '360eae3m12904263l134939190';top.langx = 'zh-tw';top.liveid = 'cbcfc6cdcec29bcdccc9cd'top.casino = 'SI2';top.hot_game = '';top.hasLogin = 'login';</script><script>window.location.href = 'http://112.78.104.13/app/member/FT_index.php?mtype=3&uid=360eae3m12904263l134939190&langx=zh-tw';</script>
仅 php 只能做到这里,虽然可析出跳转的目标页,但数据是由 js 产生的。只能得到页面框架

参考代码
$url = 'http://112.78.104.13/app/member';$url1 = 'http://112.78.104.13/app/member/login.php';$d = array('username' => 'zm1000', 'passwd' => 'a123456');//echo file_get_contents($url);//print_r(get_headers($url));echo postdata($url1, $d);function postdata($url, $data){    $opts = array(        'http' => array(            'method' => 'POST',            'header' => 'content-type:application/x-www-form-urlencoded',            'user_agent' => $_SERVER['HTTP_USER_AGENT'],            'content' => http_build_query($data)        )        );    $context = stream_context_create($opts);    $result = file_get_contents($url, false, $context);    return $result;}


只为展示使用 file_get _contents 模拟提交

1、http://112.78.104.13 是框架页。含有公共变量和函数
2、含登录框的框架是 http://112.78.104.13/app/member
3、表单目标页是 http://112.78.104.13/app/member/login.php
4、登录后返回

<script>top.uid = '360eae3m12904263l134939190';top.langx = 'zh-tw';top.liveid = 'cbcfc6cdcec29bcdccc9cd'top.casino = 'SI2';top.hot_game = '';top.hasLogin = 'login';</script><script>window.location.href = 'http://112.78.104.13/app/member/FT_index.php?mtype=3&uid=360eae3m12904263l134939190&langx=zh-tw';</script>
仅 php 只能做到这里,虽然可析出跳转的目标页,但数据是由 js 产生的。只能得到页面框架

参考代码
$url = 'http://112.78.104.13/app/member';$url1 = 'http://112.78.104.13/app/member/login.php';$d = array('username' => 'zm1000', 'passwd' => 'a123456');//echo file_get_contents($url);//print_r(get_headers($url));echo postdata($url1, $d);function postdata($url, $data){    $opts = array(        'http' => array(            'method' => 'POST',            'header' => 'content-type:application/x-www-form-urlencoded',            'user_agent' => $_SERVER['HTTP_USER_AGENT'],            'content' => http_build_query($data)        )        );    $context = stream_context_create($opts);    $result = file_get_contents($url, false, $context);    return $result;}


只为展示使用 file_get _contents 模拟提交



最后能不能给出一个地址能获取到整页数据的,我想采集这个网页上的结果

我已经说了“数据是由 js 产生的”,自然就是 php 抓不到的了

我已经说了“数据是由 js 产生的”,自然就是 php 抓不到的了



大哥你会不会采集这个数据然后写到数据库,开个价吧,
本来是有个文件的,所以写入数据库部分有参考。您直接说价格和时间,我是个痛快人!

JS的数据用PHP抓也不是不可能,只不过被对方发现了的话,这个程序的维护成本就增大

其?,?方一般不???,但???西要???才有人做。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn