thread = py4chan.b.Thread(179163238)Where 179163238 is the thread number on /b/.
l = py4chan.s.Page(0)That will list all of the thread numbers of every thread on /s/'s front page. That would be a list of integers, like: [6924541, 6924482, ..., 6924041]
thread = py4chan.gif.Post("./lulz.gif", name="person##tripcode", email="wat@wat.wat", subject="A GIF image", comment="Text goes here")That will return a Thread object, which can be used like any other.
thread = py4chan.g.Thread(7006934) for post in thread: print post.user.nameThat would print out every username to post in that thread. The following data is available in a Post object:
post.num The post number. int post.user.name The poster's name. str post.user.trip The poster's tripcode. str / None post.user.mod Is the poster a mod? bool post.user.admin Is the poster an admin? bool post.date The time of posting. str post.img.width The image's width. int / None post.img.height The image's height. int / None post.img.size The image's size. str / None post.img.filename The image's original filename. str / None post.subject The post's subject. str / None post.text The post's text. str
thread.Update()That will re-parse the information from 4chan, and re-fill that thread object.
if thread.status == py4chan.Result.OK: print "Everything went ok." elif thread.status == py4chan.Result.DEAD: print "The thread 404-ed." elif thread.status == py4chan.Result.BANNED: print "LOL. U got b&."
thread.Post(filename="./lulz.gif", name="person##tripcode", email="wat@wat.wat", subject="A GIF image", comment="Text goes here")Note that this will will send the post to 4chan, but will not alter the Thread object. Use thread.Update() to do that.
Note: While 15,000 tripcode's per second isn't necessarily slow, there are much better tripcode calulators out there. These functions are in place for novelty/experimentation purposes only. They will later be rewritten in C, and can then be used seriously.
print "moot !" + py4chan.Tripcode.Calculate("faggot") + " ## Admin"That will print out: "moot !Ep8pui8Vw2 ## Admin"
cond = lambda password: "lulz" in password.lower() source = py4chan.Tripcode.PasswordsRandom(8) for i in py4chan.Tripcode.Crack(cond, source): print iThe cond argument is a function that will return True if we want to keep this value. source is a generator that will provide all of the passwords to test. py4chan provides 2 built-in generators: