You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何导出带标签的Pocket文章列表?含Python API使用场景

How to Retrieve Pocket Articles with Custom Tags

Using the Official Pocket API

The Pocket API absolutely supports fetching your custom tags—you just need to adjust your request parameters to include full item metadata. Here's how to implement this in Python:

Step 1: Confirm Authentication Setup

First, make sure you have a valid access token from Pocket's OAuth flow. You'll need to register an app on Pocket's developer platform, then complete the authorization process to get your consumer key and access token.

Step 2: Fetch Articles with Tags Included

When calling the /v3/get endpoint, set the detailType parameter to complete—this triggers the API to return all metadata, including your custom tags for each article. Here's a working Python snippet using the requests library:

import requests

POCKET_API_ENDPOINT = "https://getpocket.com/v3/get"
request_headers = {
    "Content-Type": "application/json",
    "X-Accept": "application/json"
}
request_payload = {
    "consumer_key": "YOUR_CONSUMER_KEY",
    "access_token": "YOUR_ACCESS_TOKEN",
    "detailType": "complete",  # Required to pull tag data
    "state": "all"  # Retrieve every article, not just unread ones
}

response = requests.post(POCKET_API_ENDPOINT, json=request_payload)
articles = response.json()

# Extract and display articles with their tags
for item_id, article in articles["list"].items():
    article_title = article.get("resolved_title", article.get("given_title", "Untitled"))
    tag_dict = article.get("tags", {})
    tag_list = list(tag_dict.keys()) if tag_dict else []
    print(f"Title: {article_title}\nTags: {tag_list}\n---")

Each article's tags field comes as a dictionary where keys are your custom tag names—converting this to a list makes it easier to work with.

Alternative Non-API Method: Direct Export from Pocket

If you'd rather skip API setup, Pocket lets you export your entire library (tags included) directly from your web account:

  1. Log into Pocket on the web and click your profile icon in the top-right corner.
  2. Select Settings from the dropdown menu.
  3. Scroll to the Export section near the bottom of the page.
  4. Choose the JSON export format (it’s the most straightforward to parse programmatically, as it includes a tags array for each item).
  5. Download the file, then load and process it in Python like this:
import json

with open("pocket-export.json", "r") as export_file:
    export_data = json.load(export_file)

for article in export_data["list"]:
    article_title = article.get("resolved_title", article.get("given_title", "Untitled"))
    tag_list = article.get("tags", [])
    print(f"Title: {article_title}\nTags: {tag_list}\n---")

Quick Troubleshooting Tips

  • If tags are missing from API responses, double-check that detailType is set to complete (not simple or basic).
  • Ensure your access token has the default read permissions—these include access to tag data by default.
  • For the export method, avoid using the HTML format unless you want to manually parse tags; JSON is far more reliable for automated processing.

内容的提问来源于stack exchange,提问作者Toro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:55:21