最近失業,在網上投了很多簡曆,據說重新整理後,簡曆可以排在前面!於是就想起來做一個重新整理簡曆的小程式,碰巧在學習Python,也懶得開啟慢慢的vs了。
簡曆重新整理呀,親,比類比登入163,百度什麼的更實用!
案頭建立“簡曆重新整理.txt”,大家都懂的,尾碼修改為py,開啟!
功能很簡單,以下是代碼,可以看到濃濃的C#編碼風格。
這裡推薦大家兩款工具,一款是作為瀏覽器工具嵌入的,一款是獨立的。HttpWatch和Fiddler2,後者功能相當強大,做爬蟲必備。
import urllib.parse,urllib.request,http.cookiejar#根據路徑和POST內容來提交表單def GetUrlRequest(iUrl,iStrPostData): postdata=urllib.parse.urlencode(iStrPostData) postdata=postdata.encode(encoding='UTF8') header = {'User-Agent':'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)'} req= urllib.request.Request( url = iUrl, data = postdata, headers = header) return urllib.request.urlopen(req).read().decode("UTF8")#設定cookiecookie = http.cookiejar.CookieJar()cookieProc = urllib.request.HTTPCookieProcessor(cookie)opener = urllib.request.build_opener(cookieProc)urllib.request.install_opener(opener)#登入資訊strLoginInfo = { 'chk_remember_pwd':'on', 'user_login':'XXX@163.com', 'user_pwd':'XXX' }urlLogin='http://XXX/user/ajaxlogin/?isMd5=1'print('登入結果:'+GetUrlRequest(urlLogin,strLoginInfo))#重新整理簡曆urlRefresh='http://XXX/resume/refreshresume/'strRefresh={'res_id':'XXX'}print('重新整理結果:'+GetUrlRequest(urlRefresh,strRefresh))
我這裡使用的UTF-8,可根據不同的網站自行調節。
使用的環境是python3.2.3。
執行結果: