Attachment 'lfcookie-2.py'

Download

   1 #!/usr/bin/env python
   2 # -*- coding: GB2312 -*-
   3 # xyb at linuxforum.net
   4 
   5 import sys
   6 from urllib import urlencode
   7 import cookielib, urllib2
   8 cj = cookielib.LWPCookieJar()
   9 opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  10 urllib2.install_opener(opener)
  11 opener.addheaders = [
  12         ("User-agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3"),
  13         ("Accept", "text/html, image/jpeg, image/png, text/*, image/*, */*")]
  14 
  15 # check args
  16 if len(sys.argv) <= 2:
  17     print "Usage: %s USERNAME PASSWORD" % (sys.argv[0])
  18     sys.exit(1)
  19 else:
  20     UserName = sys.argv[1]
  21     Password = sys.argv[2]
  22 
  23 # login
  24 data = {
  25         'Loginname': UserName,
  26         'Loginpass': Password,
  27         'firstlogin': 1,
  28         'option': 'µÇÈëÂÛ̳'
  29         }
  30 urldata = urlencode(data)
  31 r = opener.open("http://www.linuxforum.net/forum/start_page.php", urldata)
  32 
  33 # show result
  34 results = r.read()
  35 open('start.html', 'w').write(results)
  36 
  37 # then, user page
  38 r = urllib2.urlopen("http://www.linuxforum.net/forum/login.php?Cat=")
  39 results = r.read()
  40 open('user.html', 'w').write(results)
  41 
  42 # read messages
  43 r = urllib2.urlopen("http://www.linuxforum.net/forum/viewmessages.php?Cat=&box=received")
  44 results = r.read()
  45 open('inbox.html', 'w').write(results)
  46 
  47 # save cookies to file
  48 cj.save("./cookies")

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2021-05-11 08:52:18, 1.5 KB) [[attachment:lfcookie-1.py]]
  • [get | view] (2021-05-11 08:52:18, 1.3 KB) [[attachment:lfcookie-2.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.