Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
213 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# crud | ||
|
||
注意:所有命令必须先进入此目录运行。 | ||
|
||
``` | ||
cd testdata/telegra-ph/hurl | ||
``` | ||
|
||
## 001.获取 cookie | ||
|
||
``` | ||
./get_cookie.sh | ||
``` | ||
|
||
执行完毕之后,会在当前目录下生成一个 .env.create 文件、cookie.txt 文件。 | ||
|
||
.env.create 包括下面内容: | ||
|
||
``` | ||
HURL_save_hash=xxxxxxxxxxxxxxxx | ||
``` | ||
|
||
cookie.txt 包括下面内容: | ||
|
||
``` | ||
# Netscape HTTP Cookie File | ||
# This file was generated by Hurl | ||
#HttpOnly_edit.telegra.ph FALSE / TRUE 1743806847 tph_uuid xxxxxxxxxxxxxx | ||
#HttpOnly_edit.telegra.ph FALSE / TRUE 1 tph_auth_alert DELETED | ||
``` | ||
|
||
### 002.新增文章 | ||
|
||
前提条件,必须先执行 001 步骤。需要读取 .env.create 文件里面的下列变量 | ||
|
||
``` | ||
HURL_save_hash | ||
``` | ||
|
||
同时需要读取 cookie.txt 文件 | ||
|
||
命令: | ||
|
||
``` | ||
./create.sh | ||
``` | ||
|
||
成功之后需要备份 cookie.txt 到 cookie.update.txt,同时需要保存下列信息到 .env.update,用于更新文章: | ||
|
||
``` | ||
HURL_save_hash | ||
HURL_page_id | ||
HURL_path | ||
``` | ||
|
||
### 003.更新文章 | ||
|
||
前提条件,必须先执行 002 步骤。需要读取 .env.update 文件里面的下列变量 | ||
|
||
``` | ||
HURL_save_hash | ||
HURL_page_id | ||
``` | ||
|
||
同时需要读取 cookie.update.txt 文件 | ||
|
||
命令: | ||
|
||
``` | ||
./update.sh | ||
``` | ||
|
||
成功之后的结果: | ||
|
||
```json | ||
{ | ||
"page_id": "xxxxxxxxxxxxxxxx", | ||
"path": "xxxxxxxxxxxxxxxx" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# 获取新token并新增文章 | ||
# getCfg | ||
POST https://edit.telegra.ph/check | ||
origin: https://telegra.ph | ||
referer: https://telegra.ph/ | ||
``` | ||
page_id=0 | ||
``` | ||
HTTP 200 | ||
[Captures] | ||
tph_uuid: cookie "tph_uuid" | ||
check_resp_body: body | ||
save_hash: jsonpath "$['save_hash']" | ||
|
||
# newArticle | ||
POST https://edit.telegra.ph/save | ||
origin: https://telegra.ph | ||
referer: https://telegra.ph/ | ||
Cookie: tph_uuid={{tph_uuid}} | ||
[MultipartFormData] | ||
Data: file,content.html;text/plain | ||
title: 测试标题 | ||
author: terwer | ||
save_hash: {{save_hash}} | ||
page_id: 0 | ||
HTTP 200 | ||
[Captures] | ||
save_resp_body: body | ||
save_page_id: jsonpath "$['page_id']" | ||
save_path: jsonpath "$['path']" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
hurl create2.hurl -v |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# newArticle | ||
POST https://edit.telegra.ph/save | ||
origin: https://telegra.ph | ||
referer: https://telegra.ph/ | ||
[MultipartFormData] | ||
Data: file,content.html;text/plain | ||
title: 测试标题 | ||
author: terwer | ||
save_hash: {{save_hash}} | ||
page_id: 0 | ||
HTTP 200 | ||
[Captures] | ||
save_resp_body: body | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
# Include the set_env.sh script directly | ||
. set_env.sh | ||
|
||
# load .env.create | ||
export $(grep -v '^#' .env.create | xargs) | ||
|
||
resp=$(hurl create.hurl --cookie cookie.txt) | ||
page_id=$(echo $resp | jq -r '.page_id') | ||
path=$(echo $resp | jq -r '.path') | ||
|
||
# save cookie for update | ||
cp cookie.txt cookie.update.txt | ||
|
||
# save data for update | ||
set_env .env.update HURL_save_hash $HURL_save_hash | ||
set_env .env.update HURL_page_id $page_id | ||
set_env .env.update HURL_path $path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 获取新token并新增文章 | ||
# getCfg | ||
POST https://edit.telegra.ph/check | ||
origin: https://telegra.ph | ||
referer: https://telegra.ph/ | ||
``` | ||
page_id=0 | ||
``` | ||
HTTP 200 | ||
[Captures] | ||
tph_uuid: cookie "tph_uuid" | ||
check_resp_body: body | ||
save_hash: jsonpath "$['save_hash']" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
# Include the set_env.sh script directly | ||
. set_env.sh | ||
|
||
resp=$(hurl get_cookie.hurl --cookie-jar cookie.txt) | ||
save_hash=$(echo $resp | jq -r '.save_hash') | ||
set_env .env.create HURL_save_hash $save_hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
# Define a method to set environment variables | ||
function set_env() { | ||
local env_file=$1 | ||
local name=$2 | ||
local new_value=$3 | ||
|
||
if [ -z "$env_file" ] || [ -z "$name" ] || [ -z "$new_value" ]; then | ||
echo "Usage: set_env <env_file> <name> <new_value>" | ||
return 1 | ||
fi | ||
|
||
if grep -q "^$name=" $env_file; then | ||
sed -i '' "s/^$name=.*/$name=$new_value/" $env_file | ||
else | ||
echo "$name=$new_value" >> $env_file | ||
fi | ||
|
||
echo "$name written to $env_file, values are:\n$name=$new_value" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# updateArticle | ||
POST https://edit.telegra.ph/save | ||
origin: https://telegra.ph | ||
referer: https://telegra.ph/ | ||
[MultipartFormData] | ||
Data: file,content.html;text/plain | ||
title: 测试标题 | ||
author: terwer | ||
save_hash: {{save_hash}} | ||
page_id: {{page_id}} | ||
HTTP 200 | ||
[Captures] | ||
save_resp_body: body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
# load .env | ||
export $(grep -v '^#' .env.update | xargs) | ||
|
||
resp=$(hurl update.hurl --cookie cookie.txt) | ||
echo $resp |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters