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

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
spoiler

Whether the attached file is spoiled.

Type:bool
timestamp

Unix timestamp for this post.

Type:int
datetime

Datetime time of this post.

Type:datetime.datetime
first_file

The File object associated with this post.

Type:py8chan.File
has_file

Whether this post has a file attached to it.

Type:bool
url

URL of this post.

Type:string
semantic_url

URL of this post, with the thread’s ‘semantic’ component.

Type:string
semantic_slug

This post’s ‘semantic slug’.

Type:string

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