basc_py4chan.Post – 4chan Post

basc_py4chan.Post allows for standard access to a 4chan post.

Example

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

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

# get the board we want
board = basc_py4chan.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('Subject', topic.subject)
print('Comment', topic.comment)

# file information
for f in first_thread.file_objects():
    print('Filename', f.filename)
    print('  Filemd5hex', f.file_md5_hex)
    print('  Fileurl', f.file_url)
    print('  Thumbnailurl', f.thumbnail_url)
    print()

Basic Usage

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

Represents a 4chan post.

post_id

int – ID of this post. Eg: 123123123, 456456456.

poster_id

int – Poster ID.

name

string – Poster’s name.

email

string – Poster’s email.

tripcode

string – Poster’s tripcode.

subject

string – Subject of this post.

comment

string – This comment, with the <wbr> tag removed.

html_comment

string – Original, direct HTML of this comment.

text_comment

string – Plaintext version of this comment.

is_op

bool – Whether this is the OP (first post of the thread).

spoiler

bool – Whether the attached file is spoiled.

timestamp

int – Unix timestamp for this post.

datetime

datetime.datetime – Datetime time of this post.

first_file

py8chan.File – The File object associated with this post.

has_file

bool – Whether this post has a file attached to it.

url

string – URL of this post.

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 basc_py4chan.Thread object with an attribute like basc_py4chan.Thread.all_posts.