看板 Python 關於我們 聯絡資訊
文字檔如下, 他其實是 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 ........<...>,SQ.@.........V&...0?.....rJ.j -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.121.210
uranusjr:open(filename, 'rb') 就行了 08/29 17:26
wadd:你的問題跟我一樣,用二進位的方式讀就行~ 08/29 18:23