急:用snoopy抓取EMS验证码,远程模拟查询单号,无法获取JSessionID的问题?
会员life169之前在PHP版块发过一篇文章叫( 用snoopy抓取EMS验证码,远程模拟查询单号,取得查询结果)
链接是:http://topic.csdn.net/u/20100715/23/d58f2006-40ea-4cab-82e3-3bbcf4cd1e9f.html
可是我在测试的过程中却遇到一个问题,JsessionID,经常会取不到,
session_start();
include("Snoopy.class.php");
$url = "http://www.ems.com.cn/qcgzOutQueryNewAction.do?reqCode=gotoSearch";
$url2 = "http://www.ems.com.cn/qcgzOutQueryNewAction.do";
$snoopy = new Snoopy;
$snoopy->fetch($url); //获取所有内容
print_r($snoopy->headers);
打印头信息,返回的是:
Array ( [0] => HTTP/1.1 200 OK [1] => Content-Type: text/html; charset=GB2312 [2] => X-Powered-By: Servlet/2.4 JSP/2.0 [3] => Accept-Ranges: bytes [4] => Connection: close [5] => Date: Tue, 15 Mar 2011 11:24:53 GMT [6] => Age: 1876 [7] => Content-Length: 22804 )
正确的返回信息应当是:
Array ( [0] => HTTP/1.1 200 OK [1] => Cache-Control: no-cache="set-cookie" [2] => Connection: close [3] => Date: Fri, 11 Mar 2011 07:42:04 GMT [4] => Content-Type: text/html; charset=GB2312 [5] => Set-Cookie: JSESSIONID=N5SMs1dMW1Wy8LJ48Z1ZhP1p2kS1GSgY5twTNxcYpz1MvgYZk0LQ!195316506; path=/ [6] => X-Powered-By: Servlet/2.4 JSP/2.0 )
前面返回的里面没有JSESSIONID, 导致在后面的查询中返回不了查询结果, 我已经整了2天了,在网上查了大量资料,还是没有头绪,现在有一个奇怪现象,如果在浏览器打开ems.php页面,过一段时间再刷新页面后,又会返回正确的headers信息,但是过一阵又不能正确返回,为什么会出现这种情况, 希望有大虾能帮我看看是怎么回事? 急
回复讨论(解决方案)
百度了一下ems的查询,有不少连接是抱怨无法查询的。
所以我怀疑ems,并没有把银子花在公众查询服务器上,在高负载下,服务器有些吃力。
应该是服务器的问题。
这个问题没法解决吗,具体发生的原因是什么? 因为有的时间段又是可以的,如果我不通过Snoopy,而是直接通过火狐浏览器访问EMS的网址,通过工具查看COOKIE,实际上里面还是会产生一个JESSIONID,为什么通过Snoopy 就获取不到这个JessionID呢?
life169。麻烦再帮我解答一下这个疑问?
昨天我也在firefox里测试了一会,还好,连续刷新都抓到了sesssionid
你说的这个现象,我以前也碰到,至今无解。
用curl吧,比snoopy稳定得多,也强大得多。在csdn里有我的源码
你好,能不能告诉你写的关于curl具体的文章链接?我没找到
另外,使用CURL 也能实现Snoopy 实现的这个EMS查询功能吗?好像贴里你有说用CURL测试成功,能否提供一下你的源码给到我参考一下。
我的邮箱是:59325460@qq.com
已经发到你的邮箱里了
life169, 非常感谢,收到你的源码,不过在使用CURL测试过程中,仍然不能返回正确数据,总是提示“页面停留时间过长导致邮件查询标志丢失,请刷新查询页面。”
搞不明白是怎么回事,还请继续指点迷津。
恩 以前做的代码不能用了
ems的查询地址变了,
也多了两个提交所需要的数据
reqCode browseBASE
myEmsbarCode 7967913886707
mailNum EE082209212CS
E4E5AFF694E4FAD581D8FC8 vpc9
optijiaot.x 15
optijiaot.y 13
这个是以前没有的 像是由js生成的,原文件里看不见。
那现在要怎么改,才能通过CURL的方式正确的获取到内容,Snoopy如果可以获取到JSESSIONID,就可以正确获取到数据。
你给我的源码需要改哪些地方吗
查询地址我之前就已经改过了,然后我觉着既然之前通过Snoopy有时可以正确查询, 可以得知CURL不成功 可
能与新增加的两个提交所需要的数据没有太大的关系,可能是其它方面的需要设置,测试的时候,
testcookie.txt 并不能生成,只会生成一个testcookiebb.txt 文件,以前从来没玩过CURL,希望
life169能帮我解决这个问题。。。
恩 现在有点忙 晚上 我弄个完整版的代码给你
好的,非常感谢life169,在这个问题上我已经整了快三天时间了!有点抓狂了。
life169,完整版的代码搞好了吗?
恩 好了 到这里下吧
http://download.csdn.net/source/3100240
太感谢了,我先测试。
测试完结,太完美了,可以正确稳定的采集EMS的数据。感谢life169,帮我了一个大忙。
life169 你好,我下载的程序,结果报错,能给我发一个新的吗pangz@sohu.com 谢谢
sea1126 你好,能把你运行成功的代码发给我吗,我运行的结果是报错,谢谢,
pang@sohu.com
恩 好了 到这里下吧
http://download.csdn.net/source/3100240
life169,您好,你这个代码我测试成功了,但是更进一步,可以绕过输入验证码这个环节么?你这个程序还是需要输入验证码的!
谢谢哥哥
能发个给我吗? 我太需要这个了。 fob001@qq.com
能给我发一份吗?我也需要这个,谢谢!
yuxianhua@vip.qq.com
我也需要 bilwy@vip.qq.com 谁有发我一份
5分啊,穷人下不起啊,发份给我好么?1991753135@qq.com,谢谢

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
