Skip to main content

PTT crawler using asyncio

Project description

AioPTTCrawler (PTT 網路版爬蟲)

This is Python Package use to crawl PTT's article data by using asyncio.

Documentation

PyPi Page

pip install AioPTTCrawler
from AioPTTCrawler import AioPTTCrawler
ptt_crawler = AioPTTCrawler()

Usage

get data from PTT

ptt_crawler = AioPTTCrawler()

BOARD = "Gossiping"
ptt_data = ptt_crawler.get_board_articles(board=BOARD, page_count=10)

ptt_data is a PTTData object. To extract data you need to use get_article_dict(), get_article_dataframe(), etc


get dict from PTTData

article_dict = ptt_data.get_article_dict()
comment_dict = ptt_data.get_comment_dict()

article's dict format

[
    {
        "article" : "Article's ID. ex:M.1663144920.A.A6E",
        "article_title" : "Article's title. ex:[公告] 批踢踢27週年活動宣導公告更新",
        "user_id" : "Author's ID. ex: ubcs",
        "user_name" : "Author's name. ex:(覺★青年超冒險蓋)",
        "board" : "BBS Board ex: Gossiping",
        "datetime" : "Post time. ex: Wed Sep 14 16:41:58 2022.",
        "context" : "Context of article. ex: PTT 27 周年活動開始囉,本篇為置底宣導,詳情參閱下面資料...",
        "ip_address" : "IP address. ex: 59.120.192.119",
        "comment_list" : [
            {"comment_dict"},
            {"comment_dict"},
        ]
    }, {"..."}
]

comment's dict format

[
    {
        "article_id" : "Article's ID. ex:M.1663144920.A.A6E",
        "tag" : "comment's reaction. ex: 推 噓 →",
        "user_id" : "User's ID. ex: bill403777",
        "comment_order" : "order of comment. ex: 1",
        "context" : "Context of comment. ex: 錢",
        "datetime" : "Post time. ex: 09/14 16:42",
        "ip_address" : "27.53.96.42",
    }, {"..."}
]

use this article for example

Comparsion

Used time difference between normal method and async method

time diff

(unit: second)

Support

You may report bugs, ask for help and discuss various other issues on the issuse

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AioPTTCrawler-0.0.5.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

AioPTTCrawler-0.0.5-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file AioPTTCrawler-0.0.5.tar.gz.

File metadata

  • Download URL: AioPTTCrawler-0.0.5.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for AioPTTCrawler-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2d59961551d12f9499c868cb2d71ec799eb3ce21e3992f253f37f53ed20591bd
MD5 96e348698a689fd39f679ca0d8a47e66
BLAKE2b-256 83153d462f051f18bfc6e22b46d97c9e1cef8769c1ae6b9101f68f6d24275d5a

See more details on using hashes here.

File details

Details for the file AioPTTCrawler-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for AioPTTCrawler-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2ca9f9e8ca21150238accc2af57e0ebfd3b4e30f86b5e5024f64d053b3db3a33
MD5 bb1f6b6a5d8fbf12db35eeafedcd890f
BLAKE2b-256 195f8c3310218e220c0439a1b4bc86a5dd8e1363a4fcbf0e90a8fa8a8c641f76

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page