C++写抓取网页信息,遇到无限循环302
首先我这样请求
GET /shop/view_shop.htm?spm=0.0.0.0.L9LHy1 HTTP/1.1\r\nHost: sytmy.tmall.com\r\nConnection: keep-alive\r\n\r\n
收到了
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 25 Jun 2013 15:54:36 GMT
Content-Type: text/html
Content-Length: 260
Connection: close
Location: http://jump.taobao.com/jump?target=http%3a%2f%2fsytmy.tmall.com%2fshop%2fview_shop.htm%3fspm%3d0.0.0.0.L9LHy1%26tbpm%3d1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<h1>302 Found</h1>
<p>The requested resource resides temporarily under a different URI.</p>
<hr/>Powered by Tengine
</body>
</html>
于是我
GET /jump?target=http%3a%2f%2fsytmy.tmall.com%2fshop%2fview_shop.htm%3fspm%3d0.0.0.0.L9LHy1%26tbpm%3d1
HTTP/1.1\r\nHost: jump.taobao.com\r\nConnection: keep-alive\r\n\r\n
然后收到
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 25 Jun 2013 16:01:02 GMT
Content-Type: text/html
Content-Length: 260
Connection: close
Set-Cookie: _tb_token_=tJ38riyPFQRX;domain=.taobao.com;Path=/;HttpOnly
Set-Cookie: cookie2=830382aa05d432adff390b7c2c3d8e8e;domain=.taobao.com;Path=/;HttpOnly
Set-Cookie: t=5c9cc299524eb1859b47d733317ee1ed;domain=.taobao.com;Expires=Mon, 23-Sep-2013 16:01:02 GMT;Path=/
P3P: CP='CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR'
Location: http://pass.tmall.com/add?_tb_token_=tJ38riyPFQRX&cookie2=830382aa05d432adff390b7c2c3d8e8e&t=5c9cc299524eb1859b47d733317ee1ed&target=http%3a%2f%2fsytmy.tmall.com%2fshop%2fview_shop.htm%3fspm%3d0.0.0.0.L9LHy1%26tbpm%3d2&pacc=u5CZYm9oGJjnLzQ4NzMqXQ==&opi=113.96.90.177&tmsc=1372176062412559
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<h1>302 Found</h1>
<p>The requested resource resides temporarily under a different URI.</p>
<hr/>Powered by Tengine
</body>
</html>
于是我再
GET /add?_tb_token_=tJ38riyPFQRX&cookie2=830382aa05d432adff390b7c2c3d8e8e&t=5c9cc299524eb1859b47d733317ee1ed&target=http%3a%2f%2fsytmy.tmall.com%2fshop%2fview_shop.htm%3fspm%3d0.0.0.0.L9LHy1%26tbpm%3d2&pacc=u5CZYm9oGJjnLzQ4NzMqXQ==&opi=113.96.90.177&tmsc=1372176062412559
HTTP/1.1\r\nHost: pass.tmall.com\r\nConnection: keep-alive\r\n\r\n
然后竟然收到
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 25 Jun 2013 16:01:44 GMT
Content-Type: text/html
Content-Length: 260
Connection: close
P3P: CP='CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR'
Set-Cookie: _tb_token_=tJ38riyPFQRX;domain=.tmall.com;Path=/
Set-Cookie: cookie2=830382aa05d432adff390b7c2c3d8e8e;domain=.tmall.com;Path=/
Set-Cookie: t=5c9cc299524eb1859b47d733317ee1ed;domain=.tmall.com;Path=/
Location: http://sytmy.tmall.com/shop/view_shop.htm?spm=0.0.0.0.L9LHy1&tbpm=1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<h1>302 Found</h1>
<p>The requested resource resides temporarily under a different URI.</p>
<hr/>Powered by Tengine
</body>
</html>
什么地方出错了?不懂啊,本人小白,请怒指出错误
[解决办法]
你忘了发cookie ...