修改并写了新的知乎剪藏模版obsidian web clipper

{
  "schemaVersion": "0.1.0",
  "name": "知乎回答 (2)",
  "behavior": "create",
  "noteContentFormat": "{{selectorHtml:.QuestionAnswer-content .RichText|markdown}}",
  "properties": [
    {
      "name": "source",
      "value": "{{url}}",
      "type": "text"
    },
    {
      "name": "author",
      "value": "{{selector:.UserLink-link|slice:1,2}}",
      "type": "multitext"
    },
    {
      "name": "publicTime",
      "value": "{{selector:.QuestionAnswer-content .ContentItem-time span}}",
      "type": "text"
    },
    {
      "name": "agreeCount",
      "value": "{{selector:.RichContent-actions .VoteButton--up}}",
      "type": "text"
    }
  ],
  "triggers": [
    "https://www.zhihu.com/question/*/answer"
  ],
  "noteNameFormat": "{{title|replace:\" - 知乎\":\"\"|replace:\"/\\(\\d+\\s*封私信\\)/g\":\"\"}}",
  "path": "Clippings"
}
  • 上面配置的导入方式:
    新用户只能上传一幅图,自己找吧(

  • 效果展示图,原文章地址

7 个赞

话说评论和图片有办法获取吗

敢尝试了下,效果不错。不过知乎专栏不能剪切。另外大佬,如果学写这类脚本的话,除了您推荐的的两个链接外还有哪些知识要了解?

1 个赞

可以看看web clipper的文档,value那里应该是类似于css选择器的那种语法,format格式化那里用的是正则语法.

这是我之前改的知乎专栏的写法(元数据都改成符合我的习惯的了),不知道现在还有没有用你可以试试看(之前跟楼主这个知乎回答一起用好像会分不清优先级,还没解决这个问题,手动选吧):

{
	"schemaVersion": "0.1.0",
	"name": "知乎专栏",
	"behavior": "create",
	"noteContentFormat": "{{content}}",
	"properties": [
		{
			"name": "source",
			"value": "{{domain}}",
			"type": "text"
		},
		{
			"name": "source-url",
			"value": "{{url}}",
			"type": "text"
		},
		{
			"name": "source-title",
			"value": "{{title|replace:\\\" - 知乎\\\":\\\"\\\"|replace:\\\"/\\(\\d+\\s*封私信\\)/g\\\":\\\"\\\"}}",
			"type": "text"
		},
		{
			"name": "author",
			"value": "{{selector:.UserLink-link|slice:1,2}}",
			"type": "multitext"
		},
		{
			"name": "publicTime",
			"value": "{{selector:.Post-Row-Content .ContentItem-time}}",
			"type": "text"
		},
		{
			"name": "agreeCount",
			"value": "{{selector:.RichContent-actions .VoteButton--up}}",
			"type": "text"
		},
		{
			"name": "description",
			"value": "{{description}}",
			"type": "text"
		},
		{
			"name": "tags",
			"value": "clippings",
			"type": "multitext"
		},
		{
			"name": "year",
			"value": "{{date|date:\\\"YYYY\\\"}}",
			"type": "text"
		}
	],
	"triggers": [
		"https://zhuanlan.zhihu.com/p/"
	],
	"noteNameFormat": "{{title|replace:\" - 知乎\":\"\"|replace:\"/\\(\\d+\\s*封私信\\)/g\":\"\"}}",
	"path": "你的仓库地址"
}