Open draveness opened 7 years ago
前排滋瓷一个.
项目作者打call ,这也想的出来。666 啊
支持。:)
这里有一个bash版的: https://github.com/aimingoo/monster/blob/master/libexec/updatesite.sh#L173
> monster update --sync-issue
写了一个python版本
import requests
import re
import json
site_url = 'http://ykksmile.top/'
sitemap_url = 'http://ykksmile.top/sitemap.xml'
token = 'token '+'*************'
username = 'cloisonne'
repo_name = 'cloisonne.github.io'
def getHTMLText(url):
try:
kv = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0'}
r = requests.get(url, timeout=30, headers=kv)
r.raise_for_status() # 检查状态码
r.encoding = r.apparent_encoding
return r.text
except:
return "产生异常"
wb_data = getHTMLText(sitemap_url)
pattern = re.compile('<loc>([a-zA-z]+://[^\s]*)</loc>')
urls = pattern.findall(str(wb_data))
print(urls)
for url in urls:
url_data = getHTMLText(url)
title_pattern = re.compile('<title>(.+)</title>')
title = title_pattern.search(url_data).group(1).replace(''','\'')
print(title.replace(''','\''))
headers = {
"Accept": "application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json",
"Accept-Encoding": "gzip, deflate, br",
'Connection': 'keep-alive',
'Host': 'api.github.com',
'Origin': site_url,
"Referer": url,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",
'Authorization': token
}
payload = {
'title': title,
'labels': ['gitment', url],
'body': url
}
payload_json = json.dumps(payload)
feedback = requests.post('https://api.github.com/repos/'+username+'/'+repo_name+'/issues',headers=headers,data=payload_json)
print(feedback)
自己写了个脚本,加到那个 script 标签中就可以了 :)
// Auto Initialize Comments
let cmtBtns = document.getElementsByClassName('gitment-comments-init-btn');
let isClicked = false;
let timer = setInterval(() => {
Array.prototype.forEach.call(cmtBtns, item => {
item.click();
isClicked = true;
if(isClicked) {
clearInterval(timer);
console.log('Clear timer.')
}
})
}, 1000)
昨天写了个自动化初始评论的脚本
详细使用可以看:https://draveness.me/git-comments-initialize