python操作网站攫取相关链接资源

 

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 )

 

 


你可能感兴趣的:(python)