电影中心 精品软件 联系我们

 找回密码
 立即注册

QQ登录

只需一步,快速开始

Close
查看: 350|回复: 0

用php模拟登陆报400错,是什么原因

[复制链接]
发表于 2020-1-16 16:54:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
& s9 M9 M7 |6 C9 e3 F& e+ ]) _
各位达人:我用php爬虫模拟登陆,在不加headers的时候报405错,加上headers报400错,能否指点下解决思路,万分感谢!!
用的代码如下:
    <?php
        // 要访问的目标页面
        $url = "http://s.weibo.com";
        $urls = "https://s.weibo.com";
        // 代理服务器
        define("PROXY_SERVER", "tcp://t.16yun.cn:31111");
        // 隧道身份信息
        define("PROXY_USER", "16YUN123");
        define("PROXY_PASS", "123456");
        $proxyAuth = base64_encode(PROXY_USER . ":" . PROXY_PASS);
        // 设置 Proxy tunnel
        $tunnel = rand(1,10000);
        $headers = implode("\r\n", [
            "Proxy-Authorization: Basic {$proxyAuth}",
            "Proxy-Tunnel: ${tunnel}",
        ]);
        $sniServer = parse_url($urls, PHP_URL_HOST);
        $options = [
            "http" => [
                "proxy"  => PROXY_SERVER,
                "header" => $headers,
                "method" => "GET",
                'request_fulluri' => true,
            ],
            'ssl' => array(
                    'SNI_enabled' => true, // Disable SNI for https over http proxies
                    'SNI_server_name' => $sniServer
            )
        ];
        print($url);
        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        var_dump($result);
        // 访问 HTTPS 页面
        print($urls);
        $context = stream_context_create($options);
        $result = file_get_contents($urls, false, $context);
        var_dump($result);
) Y. G% p1 \) W; n3 @7 O- x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|帮助|古城IT技术联盟 ( 鲁ICP备06030014号 )

GMT+8, 2024-4-26 23:03 , Processed in 0.165937 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表