Content
# Tool List
- get coze workflow data,use xhs_mcp_server to auto publish
- Program entry `auto_publish.py`, call coze workflow, output required title, content, images, and call `xhs_mcp_server` mcp for automated publishing
# Coze Workflow Run
- https://www.coze.cn/open/docs/developer_guides/workflow_run
- llm prompt
```text
# Role
You are a professional and experienced book summary generator with a deep knowledge reserve and extensive practical experience. Based on the book title input by the user, you can accurately and efficiently generate book summaries. You are proficient in using DeepSeek technology for in-depth rewriting, following the AIDA model, creating a strong sense of objectivity, substitution, and empathy, and carefully refining three high-quality summaries. You create a title and content that fit the Xiaohongshu style. Each paragraph of content is strictly controlled within 300 characters, and the core points of the book are fully and concisely presented. The rewritten Xiaohongshu title and content are output separately, with each complete sentence forming a separate line. At the same time, you ensure that the information source is accurate, and when involving related knowledge, you use search tools to obtain the latest and most reliable information.
## Skills
### Skill 1: Accurate Book Summary Generation
1. Deeply analyze the book title input by the user, comprehensively considering the theme, plot, characters, writing style, and other dimensions, using advanced text analysis methods and professional tools to automatically generate high-quality book summaries.
2. The generated book summaries accurately cover the core views, key plots, important character relationships, and other key information of the book, ensuring that the content is complete, logical, clear, and organized.
### Skill 2: In-depth Rewriting and Style Shaping
1. Proficiently use the DeepSeek tool to comprehensively and systematically rewrite the generated book summaries, refining three logical, prominent, and hierarchical summaries.
2. Closely fit the style characteristics of the Xiaohongshu platform, carefully polish from language style (such as lively, cute, and infectious) and layout (reasonable paragraphing, use of emoticons, etc.), and recreate a highly attractive and Xiaohongshu-style title and content. Each paragraph of content is controlled within 300 characters. If the content is insufficient, use language skills to expand and write, accurately convey the essence of the book, and add a 10-character subtitle to each paragraph. At the same time, combine all the content to generate a concise and powerful total title that fits the Xiaohongshu style.
### Skill 3: Deep Mining of Author Introduction
1. Use the precise search function to deeply mine the author's introduction information, ensuring that the information is accurate, complete, and timely.
2. Carefully screen and organize the searched author introduction information, extract key and valuable information, and present it to the user in a concise and vivid way.
3. Use the image search tool to find three image address information related to the book title.
### Skill 4: Guiding Reader Comments
1. Propose two questions to guide reader comments, each within 30 characters.
## Limitations:
- Only conduct book summary generation, rewriting, and author introduction mining operations around the book title input by the user, without answering unrelated topics.
- The output content is strictly organized according to the required format, with the title and each paragraph of content separately formed and displayed.
- Each paragraph of book summary content is strictly controlled within 300 characters. If it is insufficient, expand and write. The total title is concise, refined, and highly summarizes the overall content.
- When obtaining information through search tools, ensure that the information source is reliable and authoritative.
- Assign the total title to the `title` variable, delete the total title and assign the other content to the `content` variable, and output the image address information to `images`.
- The output `title/content/images` content must comply with the JSON format.
- Remove special symbols (such as , , , , etc.) from the `content`.
- All formats must comply with the JSON format and be output to downstream use.
- The answer must call the search or browser tool to obtain information, ensuring that the information source is accurate.
```
# xhs_mcp_server
- https://pypi.org/project/xhs-mcp-server/
# ref
- https://www.modelscope.cn/mcp/servers/@XGenerationLab/xhs_mcp_server Xiaohongshu MCP Publisher
- https://www.modelscope.cn/learn/1205?pid=1204 Use Qwen3+MCPs to implement AI automatic publishing of Xiaohongshu notes! Support graphics and video
# Obtain WeChat Book List (wx_bd_json.py)
- Call https://weread.qq.com/web/bookListInCategory/all?maxIndex={maxIndex}&rank={rank} to parse the required book information
```python
import time
import requests
def parse_book_data(url_template: str, start_max_index: int = 0, start_rank: int = 1) -> list:
"""
Loop through the interface returned JSON data, extract book title and author information
:param url_template: Interface URL template (must contain {maxIndex} and {rank} placeholders)
:param start_max_index: Starting maxIndex value (default 0)
:param start_rank: Starting rank value (default 1)
:return: List containing book title and author
"""
all_books = []
current_max_index = start_max_index
current_rank = start_rank
has_more = 1 # Control loop flag
while has_more < 10:
# Construct the current request URL
current_url = url_template.format(maxIndex=current_max_index, rank=current_rank)
try:
response = requests.get(current_url)
response.raise_for_status() # Raise HTTP error
data = response.json()
# Parse JSON data
books = data.get("books", [])
if not books:
break # Terminate early if no data
# Extract book title and author
for book in books:
book_info = book.get("bookInfo", {})
title = book_info.get("title", "Unknown Title")
author = book_info.get("author", "Unknown Author")
all_books.append({"Book Title": title, "Author": author})
# Update next page parameters
current_max_index += len(books) # maxIndex is usually the starting index of the next page
current_rank = 1 # rank is the starting rank of the next page
has_more += 1 # Determine if there is more data (1 means yes)
time.sleep(5)
print(
f"Obtained {len(books)} pieces of data, current maxIndex={current_max_index - len(books)}, rank=1,has_more={has_more}")
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")
break
except KeyError as e:
print(f"JSON structure exception, missing key: {e}")
break
return all_books
if __name__ == "__main__":
# Interface URL template (note: ensure the URL is valid and supports maxIndex and rank parameters)
API_URL_TEMPLATE = "https://weread.qq.com/web/bookListInCategory/all?maxIndex={maxIndex}&rank={rank}"
# Start parsing data
books_data = parse_book_data(API_URL_TEMPLATE)
# Output results
print(f"\nParsed {len(books_data)} books:")
for idx, book in enumerate(books_data, 1):
print(f"- {book['Book Title']} {book['Author']}")
```
# example
- config.yaml
```yaml
books:
- Cognitive Awakening: The Original Motivation for Self-Change Zhou Ling
phone_number: xxxxxxxxxx
cookie_path: /Users/linear/myown/cookie
agent_id: xxxxxxxxxx
workflow_id: xxxxxxxxxx
api_key: xxxxxxxxxx
multi_pic: false
```
- agent_results.json
```json
{
"book_title": "Cognitive Awakening: The Original Motivation for Self-Change Zhou Ling",
"result": "{\"content_type\":1,\"data\":\"{\\n \\\"title\\\": \\\"Cognitive Awakening: Finding the Key to Self-Change\\\",\\n \\\"content\\\": \\\"Main Title: Cognitive Awakening: Finding the Key to Self-Change\\n\\nSubtitle: Analyzing Thinking Patterns\\nCognitive Awakening deeply explains thinking patterns such as \\\"brain structure, subconsciousness, and meta-cognition\\\". Humans have instinctual brains, emotional brains, and rational brains. The first two give us short-sighted and immediate gratification nature, such as being hard to resist phone temptations not because of weak willpower. Meta-cognition allows us to reflect on our own thinking and actions, like daily reviewing things that touch us, to stay awake and correct unwise ideas.\\n\\nSubtitle: Following the Laws of Things\\nThe book explains the laws of things such as \\\"deep learning, association, and feedback\\\" to help us achieve things. Learning cannot stop at listening to lectures or reading. We need to discuss, teach others, and improve retention rates. After reading a book, we should use our own words to describe the content, think in combination with experiences, and associate related things. Ability growth has a comfort zone, stretching zone, and difficulty zone. We should be at the edge of the comfort zone and read slightly difficult books.\\n\\nSubtitle: Relieving Anxiety and Cultivating Patience\\nAnxiety comes from the large gap between desire and ability and the lack of patience. To relieve anxiety, we need to understand the growth path of \\\"learning - thinking - action - change\\\" and seek change rather than quantity when reading. To cultivate patience, we need to accept ourselves, put down burdens and face nature; learn to delay satisfaction, change confrontation to communication; and change perspectives when facing difficulties to give action meaning.\\n\\nAuthor Zhou Ling is a writer, self-media person, and mind explorer. His articles are profound yet easy to understand, often praised by readers as a refreshing stream. His articles have been reprinted by many media outlets, including the official Weibo of People's Daily.\\n\\nInteractive Questions:\\n1. Have you ever made regrettable decisions in life because of the dominance of instinctual and emotional brains?\\n2. After trying to apply the methods in the book, what noticeable changes have you experienced in cultivating patience?\\\",\\n \\\"images\\\": [\\\"https://img.alicdn.com/i3/1049653664/O1CN011p1JPT1cw9vtOhEge_!!1049653664.jpg\\\",\\\"https://qny.smzdm.com/202405/14/6642c618984523074.jpg_a200.jpg\\\",\\\"https://tu.tuibook.com/2024/02/20240202082641802.jpeg\\\"]\\n}\",\"original_result\":null,\"type_for_model\":2}"
}
```
- log
```text
/usr/local/opt/python@3.11/bin/python3.11 /Users/linear/myown/code/coze_to_xhs/src/audo_publish.py
Start processing the book: Cognitive Awakening: The Original Motivation for Self-Change Zhou Ling
HTTP Request: POST https://api.coze.cn/v1/workflow/run "HTTP/1.1 200 OK"
workflow.data {"content_type":1,"data":"{\n \"title\": \"Cognitive Awakening: Finding the Key to Self-Change\",\n \"content\": \"Main Title: Cognitive Awakening: Finding the Key to Self-Change\\n\\nSubtitle: Analyzing Thinking Patterns\\nCognitive Awakening deeply explains thinking patterns such as \\\"brain structure, subconsciousness, and meta-cognition\\\". Humans have instinctual brains, emotional brains, and rational brains. The first two give us short-sighted and immediate gratification nature, such as being hard to resist phone temptations not because of weak willpower. Meta-cognition allows us to reflect on our own thinking and actions, like daily reviewing things that touch us, to stay awake and correct unwise ideas.\\n\\nSubtitle: Following the Laws of Things\\nThe book explains the laws of things such as \\\"deep learning, association, and feedback\\\" to help us achieve things. Learning cannot stop at listening to lectures or reading. We need to discuss, teach others, and improve retention rates. After reading a book, we should use our own words to describe the content, think in combination with experiences, and associate related things. Ability growth has a comfort zone, stretching zone, and difficulty zone. We should be at the edge of the comfort zone and read slightly difficult books.\\n\\nSubtitle: Relieving Anxiety and Cultivating Patience\\nAnxiety comes from the large gap between desire and ability and the lack of patience. To relieve anxiety, we need to understand the growth path of \\\"learning - thinking - action - change\\\" and seek change rather than quantity when reading. To cultivate patience, we need to accept ourselves, put down burdens and face nature; learn to delay satisfaction, change confrontation to communication; and change perspectives when facing difficulties to give action meaning.\\n\\nAuthor Zhou Ling is a writer, self-media person, and mind explorer. His articles are profound yet easy to understand, often praised by readers as a refreshing stream. His articles have been reprinted by many media outlets, including the official Weibo of People's Daily.\\n\\nInteractive Questions:\\n1. Have you ever made regrettable decisions in life because of the dominance of instinctual and emotional brains?\\n2. After trying to apply the methods in the book, what noticeable changes have you experienced in cultivating patience?\",\n \"images\": [\"https://img.alicdn.com/i3/1049653664/O1CN011p1JPT1cw9vtOhEge_!!1049653664.jpg\",\"https://qny.smzdm.com/202405/14/6642c618984523074.jpg_a200.jpg\",\"https://tu.tuibook.com/2024/02/20240202082641802.jpeg\"]\n}","original_result":null,"type_for_model":2} https://www.coze.cn/work_flow?execute_id=7505605457399808037&space_id=7493495980332285988&workflow_id=7505245815179804691&execute_mode=2 None
Saved the result of Cognitive Awakening: The Original Motivation for Self-Change Zhou Ling to agent_results.json
title parse after Cognitive Awakening: Finding the Key to Self-Change
content parse after
Analyzing Thinking Patterns
Cognitive Awakening deeply explains thinking patterns such as "brain structure, subconsciousness, and meta-cognition". Humans have instinctual brains, emotional brains, and rational brains. The first two give us short-sighted and immediate gratification nature, such as being hard to resist phone temptations not because of weak willpower. Meta-cognition allows us to reflect on our own thinking and actions, like daily reviewing things that touch us, to stay awake and correct unwise ideas.
Following the Laws of Things
The book explains the laws of things such as "deep learning, association, and feedback" to help us achieve things. Learning cannot stop at listening to lectures or reading. We need to discuss, teach others, and improve retention rates. After reading a book, we should use our own words to describe the content, think in combination with experiences, and associate related things. Ability growth has a comfort zone, stretching zone, and difficulty zone. We should be at the edge of the comfort zone and read slightly difficult books.
Relieving Anxiety and Cultivating Patience
Anxiety comes from the large gap between desire and ability and the lack of patience. To relieve anxiety, we need to understand the growth path of "learning - thinking - action - change" and seek change rather than quantity when reading. To cultivate patience, we need to accept ourselves, put down burdens and face nature; learn to delay satisfaction, change confrontation to communication; and change perspectives when facing difficulties to give action meaning.
Author Zhou Ling is a writer, self-media person, and mind explorer. His articles are profound yet easy to understand, often praised by readers as a refreshing stream. His articles have been reprinted by many media outlets, including the official Weibo of People's Daily.
Interactive Questions:
1. Have you ever made regrettable decisions in life because of the dominance of instinctual and emotional brains?
2. After trying to apply the methods in the book, what noticeable changes have you experienced in cultivating patience?
images parse after ['https://img.alicdn.com/i3/1049653664/O1CN011p1JPT1cw9vtOhEge_!!1049653664.jpg', 'https://qny.smzdm.com/202405/14/6642c618984523074.jpg_a200.jpg', 'https://tu.tuibook.com/2024/02/20240202082641802.jpeg']
Publishing to Xiaohongshu: Cognitive Awakening: Finding the Key to Self-Change
Using phone number: xxxxxxxxxxx
Using cookie file: /Users/linear/myown/cookie
Exception managing chrome: error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json)
download_image error 420 Client Error: for url: https://img.alicdn.com/i3/1049653664/O1CN011p1JPT1cw9vtOhEge_!!1049653664.jpg
download_image error HTTPSConnectionPool(host='tu.tuibook.com', port=443): Max retries exceeded with url: /2024/02/20240202082641802.jpeg (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1016)')))
Analyzing Thinking Patterns
Cognitive Awakening deeply explains thinking patterns such as "brain structure, subconsciousness, and meta-cognition". Humans have instinctual brains, emotional brains, and rational brains. The first two give us short-sighted and immediate gratification nature, such as being hard to resist phone temptations not because of weak willpower. Meta-cognition allows us to reflect on our own thinking and actions, like daily reviewing things that touch us, to stay awake and correct unwise ideas.
Following the Laws of Things
The book explains the laws of things such as "deep learning, association, and feedback" to help us achieve things. Learning cannot stop at listening to lectures or reading. We need to discuss, teach others, and improve retention rates. After reading a book, we should use our own words to describe the content, think in combination with experiences, and associate related things. Ability growth has a comfort zone, stretching zone, and difficulty zone. We should be at the edge of the comfort zone and read slightly difficult books.
Relieving Anxiety and Cultivating Patience
Anxiety comes from the large gap between desire and ability and the lack of patience. To relieve anxiety, we need to understand the growth path of "learning - thinking - action - change" and seek change rather than quantity when reading. To cultivate patience, we need to accept ourselves, put down burdens and face nature; learn to delay satisfaction, change confrontation to communication; and change perspectives when facing difficulties to give action meaning.
Author Zhou Ling is a writer, self-media person, and mind explorer. His articles are profound yet easy to understand, often praised by readers as a refreshing stream. His articles have been reprinted by many media outlets, including the official Weibo of People's Daily.
Interactive Questions:
1. Have you ever made regrettable decisions in life because of the dominance of instinctual and emotional brains?
2. After trying to apply the methods in the book, what noticeable changes have you experienced in cultivating patience?
Publish successfully
Publish completed, result: True res: Publish successfully
sleep a while...sleep_count: 1
sleep a while...sleep_count: 2
sleep a while...sleep_count: 3
sleep a while...sleep_count: 4
sleep a while...sleep_count: 5
sleep a while...sleep_count: 6
sleep a while...sleep_count: 7
sleep a while...sleep_count: 8
sleep a while...sleep_count: 9
sleep a while...sleep_count: 10
sleep a while...sleep_count: 11
sleep a while...sleep_count: 12
sleep a while...sleep_count: 13
sleep a while...sleep_count: 14
sleep a while...sleep_count: 15
sleep a while...sleep_count: 16
sleep a while...sleep_count: 17
sleep a while...sleep_count: 18
sleep a while...sleep_count: 19
sleep a while...sleep_count: 20
sleep a while...sleep_count: 21
sleep a while...sleep_count: 22
sleep a while...sleep_count: 23
sleep a while...sleep_count: 24
sleep a while...sleep_count: 25
sleep a while...sleep_count: 26
sleep a while...sleep_count: 27
sleep a while...sleep_count: 28
sleep a while...sleep_count: 29
sleep a while...sleep_count: 30
sleep a while...sleep_count: 31
sleep a while...sleep_count: 32
sleep a while...sleep_count: 33
sleep a while...sleep_count: 34
sleep a while...sleep_count: 35
sleep a while...sleep_count: 36
sleep a while...sleep_count: 37
sleep a while...sleep_count: 38
sleep a while...sleep_count: 39
sleep a while...sleep_count: 40
sleep a while...sleep_count: 41
sleep a while...sleep_count: 42
sleep a while...sleep_count: 43
sleep a while...sleep_count: 44
sleep a while...sleep_count: 45
sleep a while...sleep_count: 46
sleep a while...sleep_count: 47
sleep a while...sleep_count: 48
sleep a while...sleep_count: 49
sleep a while...sleep_count: 50
sleep a while...sleep_count: 51
sleep a while...sleep_count: 52
sleep a while...sleep_count: 53
sleep a while...sleep_count: 54
sleep a while...sleep_count: 55
sleep a while...sleep_count: 56
sleep a while...sleep_count: 57
sleep a while...sleep_count: 58
sleep a while...sleep_count: 59
sleep a while...sleep_count: 60
log_content:
Processing the book: Cognitive Awakening: The Original Motivation for Self-Change Zhou Ling
Intelligent results saved successfully
Xiaohongshu published successfully
All processing completed, and logs have been saved to publish_log.txt
Process finished with exit code 0
```
Connection Info
You Might Also Like
markitdown
Python tool for converting files and office documents to Markdown.
OpenAI Whisper
OpenAI Whisper MCP Server - 基于本地 Whisper CLI 的离线语音识别与翻译,无需 API Key,支持...
claude-flow
Claude-Flow v2.7.0 is an enterprise AI orchestration platform.
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
ai-engineering-from-scratch
Learn it. Build it. Ship it for others. The most comprehensive open-source...
hyperframes
Write HTML. Render video. Built for agents.