最后活跃于 1748028461

import.py 原始文件
1import csv
2import requests
3
4CSV_PATH = 'PATH_TO/pocket/part_000000.csv' # getpocket export file
5API_URL = 'http://shiori.para.net/api/bookmarks'
6HEADERS = {
7 'Content-Type': 'application/json',
8 'Authorization': 'Bearer TOKEN'
9}
10
11def parse_tags(tag_string):
12 if not tag_string:
13 return []
14 return [{"name": tag.strip()} for tag in tag_string.split("|")]
15
16def import_bookmarks(csv_path):
17 with open(csv_path, newline='', encoding='utf-8') as csvfile:
18 reader = csv.DictReader(csvfile)
19 for row in reader:
20 payload = {
21 "url": row["url"],
22 "createArchive": False,
23 "public": 0,
24 "tags": parse_tags(row["tags"]),
25 "excerpt": ""
26 }
27 print(payload)
28 response = requests.post(API_URL, headers=HEADERS, json=payload)
29 print(f"Sent: {row['url']} - Status: {response.status_code}")
30
31
32if __name__ == "__main__":
33 import_bookmarks(CSV_PATH)