Re: [閒聊] 這個要怎麼parse...

看板Python作者 (說唱猜做玩)時間13年前 (2012/04/19 02:54), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/7 (看更多)
先說好我還沒試出來..0rz 然後我發現他吐回來的東西應該是xml而不是json 這是我現在的code: # -*- coding: utf-8 -*- import urllib, urllib2, httplib, cookielib '取得cookie' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) r = opener.open("http://emap.pcsc.com.tw/CheckPermission.aspx") print cj._cookies sessid = cj._cookies["emap.pcsc.com.tw"]["/"]["ASP.NET_SessionId"].value print sessid '送cookie&撈資料回來' conn = httplib.HTTPConnection("emap.pcsc.com.tw") params = urllib.urlencode({'@cityid': 01, '@commandid': 'GetTown'}) headers = {"Cookie": "ASP.NET_SessionId="+sessid, "Content-type": "application/x-www-form-urlencoded", "Accept": "text/xml"} print headers conn.request("POST", "/EMapSDK.aspx", params, headers) r = conn.getresponse() print r.status, r.reason data = r.read() print data 結果依然是"使用者權限不足" 用 wireshark 查看一下官方網頁究竟在幹些什麼.. 發現應該是少了某個 cookie 的關係(yearmonth) 現在在想說這東西到底要從哪個地方生出來0rz... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.29.98.120
文章代碼(AID): #1FZtw37o (Python)
討論串 (同標題文章)
文章代碼(AID): #1FZtw37o (Python)