回答編集履歴
2
Delete Bearer
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
> 自分が高評価したものくらい自分で探し出せという感じなのでしょうか
|
2
2
|
|
3
|
-
[teratail API](https://teratail.com/teratail-api) を利用するとよいかと思います。(アクセストークンが無くても問題はありませんが、1時間あたり30回までのアクセス制限が300回に
|
3
|
+
[teratail API](https://teratail.com/teratail-api) を利用するとよいかと思います。(アクセストークンが無くても問題はありませんが、1時間あたり30回までのアクセス制限が300回に拡大されます)
|
4
4
|
> teratail APIでは以下のようなことが可能です。
|
5
5
|
>
|
6
6
|
> 質問一覧の取得
|
@@ -36,7 +36,7 @@
|
|
36
36
|
declare -i i=1
|
37
37
|
while((i<=10))
|
38
38
|
do
|
39
|
-
curl -s -H 'Authorization: Bearer
|
39
|
+
curl -s -H 'Authorization: Bearer ...' \
|
40
40
|
-X GET 'https://teratail.com/api/v1/questions?limit=100&page='$i |
|
41
41
|
jq -r '.questions[] | select((.count_reply | tonumber) > 0) | .id' |
|
42
42
|
xargs -I@ curl -s -H 'Content-Type: application/json' -X POST \
|
1
Update shell script
test
CHANGED
@@ -18,27 +18,38 @@
|
|
18
18
|
#!/bin/bash
|
19
19
|
|
20
20
|
user='aquest'
|
21
|
+
query='
|
22
|
+
{
|
23
|
+
"query": "query QuestionAnswers($questionId: ID!) {
|
24
|
+
questionAnswers(questionId: $questionId) {
|
25
|
+
... on QuestionAnswersResultSuccess {
|
26
|
+
answers { questionId id stamps { stampedUserList } }
|
27
|
+
}
|
28
|
+
... on QuestionAnswersUnknownError { message }
|
29
|
+
}
|
30
|
+
}",
|
31
|
+
"variables": { "questionId": "@" },
|
32
|
+
"data": { "questionAnswers":{} }
|
33
|
+
}'
|
34
|
+
query="${query//$'\n'/}"
|
35
|
+
|
21
36
|
declare -i i=1
|
22
|
-
|
23
37
|
while((i<=10))
|
24
38
|
do
|
25
|
-
curl -s -H 'Authorization: Bearer
|
39
|
+
curl -s -H 'Authorization: Bearer c33618c759977ecec66fe771eb81b5432aef0e44' \
|
26
40
|
-X GET 'https://teratail.com/api/v1/questions?limit=100&page='$i |
|
27
41
|
jq -r '.questions[] | select((.count_reply | tonumber) > 0) | .id' |
|
28
|
-
xargs -I@ curl -s -H 'Content-Type: application/json' -X POST
|
29
|
-
|
30
|
-
"query": "query QuestionAnswers($questionId: ID!) { questionAnswers(questionId: $questionId) { ... on QuestionAnswersResultSuccess { answers { questionId id stamps { stampedUserList } } } ... on QuestionAnswersUnknownError { message } } }",
|
31
|
-
"variables": { "questionId": "@" },
|
32
|
-
"data": { "questionAnswers":{} }
|
33
|
-
}' https://teratail.com/api/graphql |
|
42
|
+
xargs -I@ curl -s -H 'Content-Type: application/json' -X POST \
|
43
|
+
-d "$query" https://teratail.com/api/graphql |
|
34
44
|
jq --arg user "$user" -r '
|
35
45
|
.data.questionAnswers.answers[] |
|
36
46
|
.questionId as $qid | .id as $aid |
|
37
|
-
.stamps | select(length > 0) |
|
38
|
-
select(any(.stampedUserList[] == $user)) |
|
47
|
+
.stamps | select(any(.stampedUserList[] == $user)) |
|
39
48
|
"https://teratail.com/questions/" + $qid + "#reply-" + $aid
|
40
49
|
'
|
41
50
|
: $((i++))
|
42
51
|
done
|
43
52
|
```
|
44
53
|
|
54
|
+
|
55
|
+
|