PHP curl 抓包问题
用curl抓取网页书据,成绩,课表都是用这种方法抓取的,但是抓取就不行了,报500错误
这是用httpwatch抓包工具抓取的页面,cookie正确拿到
这是要抓取的界面,数据通过post传输
<html> <head> <meta charset=gbk> </head> <body> <form action="" method="post"> 学号:<input type="text" name="user"> <br> 密码:<input type="password" name="password"> <br> <input type="submit" name="login" value="登录"> </form> </body><?php if(isset($_POST["login"])) { $login = $_POST["user"]; $password = $_POST["password"]; $url = "http://202.117.64.25/loginAction.do"; $fields = "dllx=dldl&zjh=201224080126&mm=201224080126"; $cookie1 = "D:\wamp\www\cookielogin.txt"; $cookie2 = "D:\wamp\www\cookie.txt"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch); $url = "http://202.117.64.25/xszxcxAction.do?oper=tjcx"; $fields = "zxxnxq=2014-2015-1-1&zxXaq=0&zxJxl=0011&zxZc=1&zxJc=1%2C2&zxxq=1&pageSize=20&page=1¤tPage=1&pageNo=1"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); echo $result;}?></html>
PHP代码
报错界面
回复讨论(解决方案)
第一:带上CURLOPT_REFERER试试,对方是不是有可能判断了页面来源
第二:对方的登陆页是否有隐藏参数,如果有的话需要先访问登陆页获取隐藏值再提交
第三:没看见你什么地方提交了登录的账号和密码,就是自己这边POST过来的账号和密码
$url = "http://202.117.64.25/loginAction.do";
$fields = "dllx=dldl&zjh=201224080126&mm=201224080126";
这是提交账户和密码!
CURLOPT_REFERER 要加什么?
找到两个隐藏参数,但是貌似没什么用
第一:带上CURLOPT_REFERER试试,对方是不是有可能判断了页面来源
第二:对方的登陆页是否有隐藏参数,如果有的话需要先访问登陆页获取隐藏值再提交
第三:没看见你什么地方提交了登录的账号和密码,就是自己这边POST过来的账号和密码
$url = "http://202.117.64.25/loginAction.do";
$fields = "dllx=dldl&zjh=201224080126&mm=201224080126";
这是提交账户和密码!
CURLOPT_REFERER 要加什么?
找到两个隐藏参数,但是貌似没什么用
帮你测试了一下,登录是没问题的,已经登录成功,主要问题出在你第二次请求的参数上,检查一下参数,抓取你第二个页面上所有的参数下来,另外JAVA的这个报错不是很懂!
帮你测试了一下,登录是没问题的,已经登录成功,主要问题出在你第二次请求的参数上,检查一下参数,抓取你第二个页面上所有的参数下来,另外JAVA的这个报错不是很懂!
你抓取成功了吗?
大家帮忙看看,怎么回事???
你的流程和代码都有问题!正确的流程应该是:
1、访问 http://202.117.64.25/
获取 cookie。因为他的 sessionid 在这个页面发出的
2、访问 http://202.117.64.25/loginAction.do 并发送 post 表单数据
3、第2步返回的是一个框架页,你得根据需要进入某个框架
比如访问 http://202.117.64.25/menu/s_top.jsp 可以得到已登录信息:欢迎光临 黄小龙
测试代码
<xmp><?phpinclude 'curl/curl_get.php';$url = 'http://202.117.64.25/';curl_get($url);$url = "http://202.117.64.25/loginAction.do";$d = 'dllx=dldl&zjh=201224080126&mm=201224080126';curl_get($url, $d);echo curl_get('http://202.117.64.25/menu/s_top.jsp');echo curl_get('http://202.117.64.25/menu/mainFrame.jsp');echo curl_get('http://202.117.64.25/xsxxviewAction.do');
curl_get.php
<?phpfunction curl_get($durl, $data=array()) { $cookiejar = realpath('cookie.txt'); $t = parse_url($durl); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$durl); curl_setopt($ch, CURLOPT_TIMEOUT,5); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_ENCODING, 1); //gzip 解码 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if($data) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } $r = curl_exec($ch); curl_close($ch); return $r;}
你的流程和代码都有问题!正确的流程应该是:
1、访问 http://202.117.64.25/
获取 cookie。因为他的 sessionid 在这个页面发出的
2、访问 http://202.117.64.25/loginAction.do 并发送 post 表单数据
3、第2步返回的是一个框架页,你得根据需要进入某个框架
比如访问 http://202.117.64.25/menu/s_top.jsp 可以得到已登录信息:欢迎光临 黄小龙
测试代码
<xmp><?phpinclude 'curl/curl_get.php';$url = 'http://202.117.64.25/';curl_get($url);$url = "http://202.117.64.25/loginAction.do";$d = 'dllx=dldl&zjh=201224080126&mm=201224080126';curl_get($url, $d);echo curl_get('http://202.117.64.25/menu/s_top.jsp');echo curl_get('http://202.117.64.25/menu/mainFrame.jsp');echo curl_get('http://202.117.64.25/xsxxviewAction.do');
curl_get.php
<?phpfunction curl_get($durl, $data=array()) { $cookiejar = realpath('cookie.txt'); $t = parse_url($durl); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$durl); curl_setopt($ch, CURLOPT_TIMEOUT,5); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_ENCODING, 1); //gzip 解码 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if($data) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } $r = curl_exec($ch); curl_close($ch); return $r;}
非常感谢你,成功了,但是还是不知道为什么?
这是我最终代码
<?phpinclude './curl/curl_get.php';$url = "http://202.117.64.25/loginAction.do";$d = 'dllx=dldl&zjh=201224080126&mm=201224080126';curl_get($url, $d);echo curl_get('http://202.117.64.25/xszxcxAction.do?oper=tjcx', 'zxxnxq=2014-2015-1-1&zxXaq=0&zxJxl=0011&zxZc=11&zxJc=2&zxxq=2&pageSize=20&page=1¤tPage=1&pageNo=');?>

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Laravel simplifie la gestion des données de session temporaires à l'aide de ses méthodes de flash intuitives. Ceci est parfait pour afficher de brefs messages, alertes ou notifications dans votre application. Les données ne persistent que pour la demande ultérieure par défaut: $ demande-

L'extension PHP Client URL (CURL) est un outil puissant pour les développeurs, permettant une interaction transparente avec des serveurs distants et des API REST. En tirant parti de Libcurl, une bibliothèque de transfert de fichiers multi-protocol très respectée, PHP Curl facilite Efficient Execu

Alipay Php ...

Laravel fournit une syntaxe de simulation de réponse HTTP concise, simplifiant les tests d'interaction HTTP. Cette approche réduit considérablement la redondance du code tout en rendant votre simulation de test plus intuitive. L'implémentation de base fournit une variété de raccourcis de type de réponse: Utiliser illuminate \ support \ faades \ http; Http :: faux ([[ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Voulez-vous fournir des solutions instantanées en temps réel aux problèmes les plus pressants de vos clients? Le chat en direct vous permet d'avoir des conversations en temps réel avec les clients et de résoudre leurs problèmes instantanément. Il vous permet de fournir un service plus rapide à votre personnalité

L'article traite de la liaison statique tardive (LSB) dans PHP, introduite dans PHP 5.3, permettant une résolution d'exécution de la méthode statique nécessite un héritage plus flexible. Problème main: LSB vs polymorphisme traditionnel; Applications pratiques de LSB et perfo potentiel

L'article traite des fonctionnalités de sécurité essentielles dans les cadres pour se protéger contre les vulnérabilités, notamment la validation des entrées, l'authentification et les mises à jour régulières.

L'article examine l'ajout de fonctionnalités personnalisées aux cadres, en se concentrant sur la compréhension de l'architecture, l'identification des points d'extension et les meilleures pratiques pour l'intégration et le débogage.
