一條咸魚
    • 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
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

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

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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
    • Note Insights New
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy 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
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

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

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ## 什麼是 TLS 指紋?(身分證檢查) ### 1. TLS 握手 (TLS Handshake) * 當你在瀏覽器輸入 https:// 時,你的電腦(客戶端)和網站(伺服器)必須先進行一次「握手」,約定好接下來怎麼傳輸加密資料 * Client Hello: 這是握手的第一步。你會把你所有的「特徵」一次秀給伺服器看。包含: * 加密套件 (Cipher Suites): 你支援哪些加密演算法? * TLS 版本: 你支援多新的協定?(TLS 1.2 或 1.3) * 擴充欄位 (Extensions): 其他附加資訊。 ### 2. 指紋 (Fingerprinting) 與 JA3 / JA4 * 真人用戶大多使用 Chrome、Safari 或 Edge 瀏覽器。這些瀏覽器的「加密套件排列順序」是固定的,就像合法的身分證。 * 爬蟲程式 (Python) 預設使用 Python 內建的 OpenSSL 函式庫。它的「加密套件排列順序」和瀏覽器完全不同。 #### 什麼是 JA3 / JA4? * JA3 (舊標準): 保全把你提供的所有特徵(加密套件、順序等)串起來,算出一串代碼(雜湊值)。如果這串代碼對應的是「Python 腳本」,保全直接把你踢出去。 * JA4 (2025 新標準): JA3 已經不夠用了,因為有些駭客會偽造。JA4 除了看握手特徵,還會檢查更底層的「傳輸方式」(TCP/QUIC)。這就像保全不只看你的身分證,還看你的走路姿勢和心跳頻率。 * 那串亂碼 (t13d1717h2...): 這就是 JA4 算出來的指紋。t13 可能代表 TCP 封包特徵,後面代表加密特徵。 以前你只要換 IP(換衣服)就能混進去;現在如果你用 Python 預設設定,你的「骨架」(JA4 指紋)會直接暴露你不是人,就算 IP 再乾淨也會被擋。 ### TLS 偽裝 (偽造身分證) curl_cffi 就是用來解決上述問題的工具。 #### 1. curl_cffi 與 瀏覽器模擬 (Impersonation) * curl_cffi 是一個革命性的 Python 函式庫,它底層綁定了 curl-impersonate。這使得 Python 開發者可以調用一個經過修改的 cURL 版本,該版本能夠精確複製 Chrome、Edge 或 Safari 的 TLS 握手特徵 。 * 既然你的「Python 身分證」會被識破,curl_cffi 就是一個「高級假證件製造商」。 * 運作方式: * 當你設定 impersonate="chrome124" 時,這個程式會精確模仿 Chrome 第 124 版的行為。 * 它會調整加密套件的順序、偽造擴充欄位,讓網站的 WAF 認為:「喔!這是一個合法的 Chrome 瀏覽器用戶。」 * API 相容性: 它提供了與 requests 高度相容的介面,降低了學習曲線。 * 非同步支援: 支援 AsyncSession,結合了偽裝能力與高並發效能。 ``` from curl_cffi import requests # 模擬 Chrome 124 瀏覽器,這將生成與真實 Chrome 相同的 JA4 指紋 response = requests.get( "https://www.walmart.com", impersonate="chrome124", headers={"User-Agent": "Mozilla/5.0..."} # 仍需設定對應的 User-Agent ) ``` * 為什麼標準 requests 不行? 因為標準的 Python requests 庫太誠實了,它無法改變底層的握手特徵,一伸手就被抓。 #### tls_client 與其他選擇 除了 curl_cffi,tls_client 也是一個強大的選擇,它基於 Golang 的 uTLS 庫。它提供了更細粒度的控制,允許開發者手動定義握手參數。然而,curl_cffi 由於其更貼近 Python 原生生態的設計和對 asyncio 的更好支援,目前在 Python 社群中更為流行 。 ### IP 代理策略 如果 TLS 指紋是「身分證」,那 IP 地址就是你的「臉」或「衣服」。 #### 1. 為什麼要輪替 IP? 如果你一直用同一個 IP 發送幾千次請求,就像同一個人每秒鐘都要進出夜店一次,保全一定會把你列入黑名單。所以你需要「千人千面」。 #### 2. IP 的階級 (由低到高) * 資料中心代理 (Datacenter IPs): 便宜、速度快,但信任度極低。僅適用於無防禦的目標或作為簡單 API 的跳板。 * 住宅代理 (Residential IPs): 來自真實家庭 ISP 的 IP 地址。這是 2025 年爬蟲的標準配備。由於它們與普通用戶共用網段,極難被封鎖。 * 行動代理 (Mobile 4G/5G IPs): 信任度最高。由於行動網路廣泛使用 CGNAT(Carrier-Grade NAT),數千名真實用戶共享同一個對外 IP,因此網站極少封鎖行動 IP,以免誤殺真實用戶。但成本極高 。 #### CGNAT (Carrier-Grade NAT) 為什麼行動代理 (Mobile IP) 最強? * 因為手機基地台的 IP 數量不夠用,電信商使用了一種技術叫 CGNAT。 * 這意味著,可能有 1,000 個真實人類用戶,背後共用同一個對外 IP 地址。 * 網站(Amazon/Walmart)不敢封鎖行動 IP。因為如果封鎖了這個 IP,會誤殺那 1,000 個無辜的真實手機用戶。這就是爬蟲的「免死金牌」。 #### 輪替策略 (Rotation) * 隨機輪替 (Random): 每次請求換一個 IP。適用於查價(不需要登入,看完就跑)。 * 黏性會話 (Sticky Session): 在一段時間內固定用同一個 IP。 * 為什麼需要? 假設你要登入帳號並結帳。如果你登入時在「台灣」,下一秒加入購物車變成了「美國」,網站會覺得帳號被盜而強制登出。所以你需要 session_id 來告訴代理商:「接下來 10 分鐘,請給我同一個 IP。」

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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