浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

python 的cookie处理操作

http://blog.csdn.net/yatere/article/details/6649139

 

 

  1. cookies = http.cookiejar.CookieJar()
  2. opener = urllib.request.build_opener(urllib.request.HTTPRedirectHandler(), urllib.request.HTTPCookieProcessor(cookies))
  3.  
  4. contents = open(upfile, 'rb').read()
  5. imgparams = [('action', b'upload'), ('filename', bytes(filename, encoding = 'utf8')), ('text', b'Powered by Python'), ('token', bytes(etoken, encoding = 'utf8')), ('file', contents)]
  6. imgparams = enc_multipart(imgparams)
  7. ctype, imgdata = imgparams
  8. imageup = urllib.request.Request('http://tlwiki.org/api.php?&bot', imgdata, {'Content-Type': ctype})
  9. opener.open(imageup)

 

 


posted on 2012-02-14 21:35  lexus  阅读(204)  评论(0编辑  收藏  举报