Hua Tung Shi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
PTTCrawler === ###### tags: `Insowe` ## GitHub [GitHub](https://github.com/GundamBox/PttCrawler) ## 功能模組 - [x] 爬蟲 - [x] 使用者資訊 - [x] 各版發文資訊 - [x] 各版回文資訊 - [x] ASN查詢 - [x] 資料庫 - [x] 欄位設計 - [x] 腳本 - [x] 爬蟲(排程腳本設計) - [x] CSV匯出 - [x] ODS匯出 - [x] 查詢 * Input - board_name, start_at, end_at * Output - board_name, start_at, end_at, domestic_ip, foreign_ip ## python套件 LICENSE - alembic **MIT License** - selenium **Apache License 2.0** - SQLAlchemy **MIT License** - ipwhois **BSD 2-Clause Simplified License** - pyexcel-ods **BSD 3-Clause License** - python-crontab **GNU Lesser General Public License v3.0** ## Todo ### [急][重要] - 要滿足客戶的基本功能 - [x] 1. 控制碼 * [x] ~~選擇用bsdconv套件去除控制碼~~ - 用selenuim解決 - 筆記 * [BBS crawler for Taiwan](https://www.slideshare.net/Buganini/bbs-crawler-for-taiwan) * [pyte](https://github.com/selectel/pyte) * [bsdconv](https://github.com/buganini/bsdconv) * [bug5](https://github.com/buganini/bug5) * [控制字元](http://donsnotes.com/tech/charsets/ascii.html#cntrl) * [x] 選擇用selenuim連上ptt的websocket版本,因為版面由CSS上色,可以直接拿原字串 - [x] 上次上站時間、上次上站IP、有效文章、登入次數 - [x] 要做瀏覽器的例外處理,如果在user電腦找不到Chrome或者Firefox要提醒 - [x] 2. 匯出功能 * Sheet - [x] Atricle - [x] Push - [x] User * [x] CSV * [x] 要找ODS輸出套件 - [x] [pyexcel-ods](https://github.com/pyexcel/pyexcel-ods) - [x] ~~[odswriter](https://github.com/mmulqueen/odswriter)~~ - [x] 3. IpAsn腳本 - [x] 4. 排程腳本 * [x] 1. 加log - crontab不給stdout,要埋簡單的log才能測試功能有沒有正常跑 - [x] 5. 查詢功能 - [x] 6. PttArticleCrawler的`crawling`方法要分為兩個,一個負責抓取`index`跟`web_id`,一個負責抓取與`web_id`對應的文章 - [x] 7. 記錄上次執行結果,避免從頭開始跑 - [x] 8. 文章跟推文的版本控制及變數 * 新增動作`add`跟`upgrade` ### [急][不重要] - 現在不做未來可能留地雷或影響功能 - [x] 1. 文章爬蟲被PTT擋連線 * [cloudflare-scrape](https://github.com/Anorov/cloudflare-scrape) - 沒有用,可能是cloudflare有改版 - 直接帶cloudflare回傳的cookie就有解了 * 可能是`requests`套件不含一般瀏覽器的cookie,考慮用selenuim解決,實際效果待測試 * 要測是不是被cloudflare擋 - 要帶cloudflare的cookie - [x] 被斷線的時候用Browser連線 * 測是不是要帶cookie - [x] 被斷線的時候用pythn.requests連線 * 測是不是被擋IP - [x] 2. term.ptt.cc也會防機器人,查詢user id速度太快會被強制斷線 * 原因是Buffer還沒拿完就get_buffer,導致抓不到正確資料,頁面就跑掉了,目前測了300個user id * Handle斷線的事件 * 找適當的delay時間 ### [不急][重要] - 現在不做未來會不好debug pass ### [不急][不重要] - 不影響功能,但會影響使用心情(X) - [ ] 1. 爬文章執行速度緩慢 * 卡在DB ## 要問小莊的問題 - [x] 推文的更新流程 * 小莊: 文章每抓一個版本, 留時間, 跟版本序號放到 db 裡面, 不用跟舊的比對, 一直抓新的加到 db 裡面去 * 3.3.1這個步驟是因為如果要比對哪些推文是已經存在的很耗時間也很麻煩,所以先刪掉全部再加回來,但缺點是萬一文章沒修過但推文有被修過,就會遺失那個推文,所以要問小莊這樣實作OK嗎? 1. 抓文章,新文章跳到(2),舊文章跳到(3) 2. 新文章 1. 新增article, article_history 2. 將整串推文加到最新的文章歷史記錄 3. 舊文章 1. 檢查舊文章有沒有修改,有修改跳到(2),沒修改跳到(3) 2. 有修改 1. 新增文章歷史記錄 2. 整串推文加到最新的記錄 3. 沒修改 1. 刪掉最近記錄的文章推文 2. 把新爬到的推文加回去 - [x] 匯出功能 * 小莊: 就分開SHEET,只要有匯出即可,文章可以先統一先匯最新版本 * 全部欄位弄在一起匯出會很雜,所以osd匯出會把有相關的資料整理在一個sheet,並分成多個sheet,而csv匯出則分成多個子檔案 * sheet - article * web_id * board_name * author * title * content * post_ip - asn - asn_cidr - asn_country_code - asn_date - asn_description - asn_registry * post_datetime * last_end_at - push * article_web_id * push - username - tag - content - ip * asn * asn_cidr * asn_country_code * asn_date * asn_description * asn_registry - datetime - user_record * username * login_times * valid_article_count * login_datetime * login_ip - asn - asn_cidr - asn_country_code - asn_date - asn_description - asn_registry - [x] 使用者上站紀錄 * 抓使用者上站紀錄比較沒什麼用途,而且PTT使用者10萬上下,很難一次抓完,建議改成要查詢特定使用者有效文章數及上站次數的時候再查

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully