Skip to content

Instantly share code, notes, and snippets.

@JiapengLi

JiapengLi/flomo.py

Created Dec 13, 2020
Embed
What would you like to do?
使用命令行创建flomo
#!/bin/env python
# -*- coding: UTF-8 -*-
import os, sys, re
import requests
'''
## 使用方法
0. 安装python,安装requests包 (pip install requests)
1. 系统创建环境变量FLOMOAPI,内容可于https://flomoapp.com/mine?source=incoming_webhook获取
2. 保存此文件至本地路径,命名为flomo.py
3. 将存放flomo.py的路径添加至系统PATH路径中
4. 执行 flomo.py '文本...'
## 说明
1. 文本中不包含#的,将会增加`#待整理`标签
2. 独立的文本参数分行记录
## 注意
- 命令行输入#,请使用单引号括起来,否则会被当成注释
- 文本中有空格的,请使用单引号括起来,否则会被识别为多行
'''
headers = {'Content-Type': 'application/json;charset=UTF-8'}
flomoapi=os.getenv('FLOMOAPI')
if not flomoapi:
print("请先创建 FLOMOAPI 环境变量")
exit()
if len(sys.argv) <= 1:
print("姿势不对。用法:flomo.py '文本...'")
exit()
content=''
for argv in sys.argv[1:]:
content += argv + '\n'
if '#' not in content:
content = '#待整理\n' + content
r = requests.post(flomoapi, headers=headers, json={'content':f'{content}'})
print("----------------")
print(content)
print("----------------")
if r.status_code == 200:
print ('MEMO 创建成功')
else:
print ('MEMO 创建失败。内容宝贵,请注意保存!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment