作者zha0 (这个帐号是挂网用)
站内Python
标题[问题] 档案处理 - 文字与二进位 - 混合使用
时间Mon Aug 29 16:41:06 2011
文字档如下, 他其实是 http 的东西 , 但今天他被存成一个档案 , 我要怎麽爬 header 然後抓里面的资料 ?
怎样才能一行一行读 , 然後到了要 binary 的地方, 就用 binary 在处理 ?____
GET /13531.jsp?/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Connection: Keep-Alive
HTTP/1.1 200 OK
Date: Thu, 17 Mar 2011 09:53:56 GMT
Server: Apache/1.3.20 (Unix) (Red-Hat/Linux)
accept-type: x-wav/y-img
Content-Type: application/octet-stream
Content-Length: 2
Age: 5
Via: 1.1 wsgnode2
你&...0?.....是.........&...0?..3i&...0?..1o(很多 ..............)
GET /13548.jsp?/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Connection: Keep-Alive
HTTP/1.1 200 OK
Date: Thu, 17 Mar 2011 09:53:58 GMT
Server: Apache/1.3.20 (Unix) (Red-Hat/Linux)
accept-type: x-wav/y-img
Content-Type: application/octet-stream
Content-Length: 2
Age: 2
Via: 1.1 wsgnode2
5.23490........vj...波ㄉˇ.....
GET /13554.jsp?/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Connection: Keep-Alive
HTTP/1.1 200 OK
Date: Thu, 17 Mar 2011 09:54:13 GMT
Server: Apache/1.3.20 (Unix) (Red-Hat/Linux)
accept-type: x-wav/y-img
Content-Type: application/octet-stream
Content-Length: 43
Age: 15
Via: 1.1 wsgnode2
........<...>,
[email protected]&...0?.....rJ.j
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.121.210
1F:→ uranusjr:open(filename, 'rb') 就行了 08/29 17:26
2F:推 wadd:你的问题跟我一样,用二进位的方式读就行~ 08/29 18:23