py8chan.Post – 8chan Post

py8chan.Post allows for standard access to a 8chan post.

Example

Here is a sample application that grabs and prints py8chan.Thread and py8chan.Post information:

# credits to Anarov for improved example
from __future__ import print_function
import py8chan

# get the board we want
board = py8chan.Board('v')

# select the first thread on the board
all_thread_ids = board.get_all_thread_ids()
first_thread_id = all_thread_ids[0]
thread = board.get_thread(first_thread_id)

# print thread information
print(thread)
print('Sticky?', thread.sticky)
print('Closed?', thread.closed)
print('Replies:', len(thread.replies))

# print topic post information
topic = thread.topic
print('Topic Repr', topic)
print('Postnumber', topic.post_number)
print('Timestamp', topic.timestamp)
print('Datetime', repr(topic.datetime))
print('Filemd5hex', topic.file_md5_hex)
print('Fileurl', topic.file_url)
print('Subject', topic.subject)
print('Comment', topic.comment)
print('Thumbnailurl', topic.thumbnail_url)

Basic Usage

class py8chan.Post(thread, data)[source]

Represents a 4chan post.

post_id

ID of this post. Eg: 123123123, 456456456.

Type:int
poster_id

Poster ID.

Type:int
name

Poster’s name.

Type:string
email

Poster’s email.

Type:string
tripcode

Poster’s tripcode.

Type:string
subject

Subject of this post.

Type:string
comment

This comment, with the <wbr> tag removed.

Type:string
html_comment

Original, direct HTML of this comment.

Type:string
text_comment

Plaintext version of this comment.

Type:string
is_op

Whether this is the OP (first post of the thread)

Type:bool
timestamp

Unix timestamp for this post.

Type:int
datetime

Datetime time of this post.

Type:datetime.datetime
first_file

The first file of the post.

Type:File
all_files[source]

Returns the File objects of all files in the post.

Type:File
extra_files[source]

Returns the File objects of all extra files in the post, if any.

Type:File
has_file

Whether this post has a file attached to it.

Type:bool
has_extra_files

Whether this post has more than one file attached to it.

Type:bool
url

URL of this post.

Type:string
Undefined Attributes (Not implemented in 8chan API. Do not use.):
poster_id (int): Poster ID. file_deleted (bool): Whether the file attached to this post was deleted after being posted. semantic_url (string): URL of this post, with the thread’s ‘semantic’ component. semantic_slug (string): This post’s ‘semantic slug’.

Post objects are not instantiated directly, but through a py8chan.Thread object with an attribute like py8chan.Thread.all_posts.