{"id":21077731,"url":"https://github.com/howie6879/w2b","last_synced_at":"2025-05-16T08:31:06.788Z","repository":{"id":43031606,"uuid":"208086424","full_name":"howie6879/w2b","owner":"howie6879","description":"将微信接收的文章自动解析同步到Bear","archived":false,"fork":false,"pushed_at":"2019-09-22T13:31:06.000Z","size":1470,"stargazers_count":41,"open_issues_count":0,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T22:11:15.231Z","etag":null,"topics":["bear","wechat"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/howie6879.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-12T15:41:49.000Z","updated_at":"2025-03-08T09:33:40.000Z","dependencies_parsed_at":"2022-09-16T12:01:32.400Z","dependency_job_id":null,"html_url":"https://github.com/howie6879/w2b","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howie6879%2Fw2b","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howie6879%2Fw2b/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howie6879%2Fw2b/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howie6879%2Fw2b/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/howie6879","download_url":"https://codeload.github.com/howie6879/w2b/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254496093,"owners_count":22080649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bear","wechat"],"created_at":"2024-11-19T19:38:03.624Z","updated_at":"2025-05-16T08:31:01.780Z","avatar_url":"https://github.com/howie6879.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 利用微信同步文章到Bear\n\n在我日常工作中，我会将各种互联网以及生活中产出的信息汇总到Bear，再通过Bear的云同步使我各个终端的信息保持一致。以前在使用有道云笔记的时候，有个功能我很喜欢，就是当看到一篇想收藏的文章的话，就可以直接右上角发送到有道云笔记。\n\n我现在面临的需求是能不能在看到喜欢的文章的时候，也通过类似于点击右上角`分享一下`就可以直接将文章同步到我各个终端上的`Bear`，最终效果如下：\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./images/w2b_demo.gif\"/\u003e\n\u003c/p\u003e\n\n### 解决方案\n\n要实现上述的需求，我大概思考了如下的解决方案：\n\n1.  准备一个微信号（这里直接称作小号）专门接收待收藏到Bear的文章\n    \n2.  编写一个服务监控小号的消息，比如收到推文类型的消息就进行内容提取\n    \n3.  监控服务将提取后的内容发送到Bear（这里要求服务运行在Mac OS上）\n    \n\n所以在继续之前，你需要有以下条件：\n\n-   基本的Python基础知识（写小脚本Python真的很方便）\n    \n-   一台装有Bear的Mac OS\n\n### 使用\n\n```shell\ngit clone https://github.com/howie6879/w2b\ncd w2b\n# 推荐使用pipenv 你也可以使用自己中意的环境构建方式\npipenv install --python=/Users/howie6879/anaconda3/envs/python36/bin/python3.6  --skip-lock\n# 运行前需要填好配置文件\npipenv run python w2b/run.py\n```\n\n首先请按照[利用微信同步文章到Bear](https://mp.weixin.qq.com/s/qRQO9xMvGTQL-ysolXJAxQ)提到的方式确定以下常量：\n\n-   S_ACCOUNT_ID：微信发送账户ID，可以在`Account/userinfo.data`下查看\n\n-   R_ACCOUNT_ID：微信接收账户ID，同上\n    \n-   RAW_KEY：解密Key，就是上面介绍的64位字符串\n    \n-   DB_PATH_TEM：定义的是消息DB路径，比如：\"/Users/howie6879/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/{0}/Message/\"\n\n对应是 `w2b/config.py` 中的配置：\n\n```python\nimport os\n\nfrom w2b.utils.tools import gen_md5\n\n\nclass Config:\n    # 微信发送账户ID\n    S_ACCOUNT_ID = os.environ.get(\"S_ACCOUNT_ID\", \"\")\n    # 微信接收账户ID\n    R_ACCOUNT_ID = os.environ.get(\"R_ACCOUNT_ID\", \"\")\n    # 解密Key\n    RAW_KEY = os.environ.get(\"RAW_KEY\", \"\")\n    # 消息DB路径\n    DB_PATH_TEM = \"/Users/howie6879/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/{0}/Message/\"\n    # 微信接收账户所有消息DB文件夹\n    MSG_DB_DIR = DB_PATH_TEM.format(gen_md5(R_ACCOUNT_ID))\n    # 与目标微信账户的聊天表\n    MSG_TABLE_NAME = f\"Chat_{gen_md5(S_ACCOUNT_ID)}\"\n    # 笔记Tag\n    BEAR_TAG = \"资源/微信\"\n    # 多久扫描一次，单位是S\n    INTERVAL = 10\n```\n\n### 最后\n\n欢迎提 `Issue`，希望可以帮到你~","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowie6879%2Fw2b","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowie6879%2Fw2b","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowie6879%2Fw2b/lists"}