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('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
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
-
timestamp¶ Unix timestamp for this post.
Type: int
-
datetime¶ Datetime time of this post.
Type: datetime.datetime
-
file_md5¶ MD5 hash of the file attached to this post.
Type: string
-
file_md5_hex¶ Hex-encoded MD5 hash of the file attached to this post.
Type: string
-
filename¶ Original name of the file attached to this post.
Type: string
-
file_url¶ URL of the file attached to this post.
Type: string
-
file_extension¶ Extension of the file attached to this post. Eg:
png,webm, etc.Type: string
-
file_size¶ Size of the file attached to this post.
Type: int
-
file_width¶ Width of the file attached to this post.
Type: int
-
file_height¶ Height of the file attached to this post.
Type: int
-
file_deleted¶ Whether the file attached to this post was deleted after being posted.
Type: bool
-
thumbnail_width¶ Width of the thumbnail attached to this post.
Type: int
-
thumbnail_height¶ Height of the thumbnail attached to this post.
Type: int
-
thumbnail_fname¶ Filename of the thumbnail attached to this post.
Type: string
-
thumbnail_url¶ URL of the thumbnail attached to this post.
Type: string
-
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.Threadobject with an attribute likebasc_py4chan.Thread.all_posts.-