forked from pysunday/sdenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: sdenv-extend更新到1.2、样例use-proxy文档
- Loading branch information
1 parent
a1d2fa2
commit 7f424da
Showing
17 changed files
with
18,482 additions
and
7 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 |
---|---|---|
|
@@ -12,3 +12,4 @@ yarn.lock | |
*.swp | ||
build/ | ||
*.node | ||
*/**/*-7802 |
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
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 |
---|---|---|
@@ -1 +1,53 @@ | ||
该example通过代理请求网站生成cookie,作者用于开发使用,用户无需关注 | ||
## 样例说明 | ||
|
||
为了模拟浏览器与sdenv运行相同瑞数vmp代码生成一摸一样的cookie的复现方法与源文件。 | ||
|
||
## 启动代理 | ||
|
||
该样例需要使用代理工具,推荐代理工具:[sd_proxy](https://github.com/pysunday/tools-proxy),该工具为自研工具,支持网站资源的收集与回放 | ||
|
||
启动代理回放:`sd_proxy -H 0.0.0.0 -p 3000 -n playback -d pysunday-proxy --log` | ||
|
||
## 应用代理 | ||
|
||
浏览器端需要使用SwitchyOmega配置并应用3000端口转发。 | ||
|
||
sdenv需要使用jsdomFromUrl方法传入代理配置`proxy: "http://127.0.0.1:3000"`。 | ||
|
||
## 获取cookie | ||
|
||
该example对应的访问链接为:`https://wcjs.sbj.cnipa.gov.cn/sgtmi` | ||
|
||
假设代理配置完全ok,则请求该链接时会返回html内容为文件[pysunday-proxy/wcjs.sbj.cnipa.gov.cn/sgtmi/format](./pysunday-proxy/wcjs.sbj.cnipa.gov.cn/sgtmi/format),可以看到html中存在代码: | ||
|
||
```javascript | ||
.getHandle('cookie')({ | ||
log: false, | ||
setCb: (val) => { | ||
if (val.includes('goN9uW4i0iKzT')) { | ||
cookies.push(val); | ||
if (cookies.length === 3) { | ||
console.log(`第三次cookie值写入:${val}`); | ||
debugger; | ||
} | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
其中第三次cookie的值即为最终发起请求的cookie值。 | ||
|
||
* node端: node中直接执行`node-9229 example/use-proxy/index.js`,命令操作符中会打印cookie值后退出 | ||
* 浏览器端: 浏览器端需要打开开发面板后再请求网址`https://wcjs.sbj.cnipa.gov.cn/sgtmi`,在断点处即可看到cookie值 | ||
|
||
## 结论 | ||
|
||
作者电脑系统版本:macOS(13.4) | ||
|
||
作者浏览器版本:Chrome Canary(121.0.6124.0) | ||
|
||
作者node和浏览器分别运行后断点处打印的值都为`goN9uW4i0iKzT=0o6uz9peZ4RlIIiCpo6uz9F9f4zZghSX8vcCtuqn0xNaRncrIKsE8SR4aRoGLBGiDlCiw69spB51I78BjEbiyeIPgiMdhjjQvrJQ.7iwYLKrWMPMi0xRa.xN64KvZGbXlPfFz0OaiHM8o.IvfnXEaf0RuNFu5VKDSSevbBeiVFAqzWPD_gZzXwDmJnf6bpaet1yyg2lmCOWCzUre8W52LiD2U95ZxkI2jrAzmfpcdX.V; path=/; expires=Tue, 12 Mar 2024 09:42:17 GMT` | ||
|
||
如果您的系统及浏览器与作者一致,那么您可以直接运行该样例复现。 | ||
|
||
当然,您也可以参考`browser/chrome`目录下的文件内容,新建一个browser并将您浏览器的值填如后参考前面方法进行试验,如果试验成功请提交您browser代码的pr,并写明您操作系统版本及浏览器版本,感谢! |
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
128 changes: 128 additions & 0 deletions
128
.../use-proxy/pysunday-proxy/wcjs.sbj.cnipa.gov.cn/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js/info
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,128 @@ | ||
{ | ||
"url": "wcjs.sbj.cnipa.gov.cn/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js", | ||
"url_full": "https://wcjs.sbj.cnipa.gov.cn/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js", | ||
"params": { | ||
"header_method": "GET" | ||
}, | ||
"request": { | ||
"http_version": "HTTP/1.1", | ||
"headers": { | ||
"fields": [ | ||
[ | ||
"Host", | ||
"wcjs.sbj.cnipa.gov.cn" | ||
], | ||
[ | ||
"Connection", | ||
"keep-alive" | ||
], | ||
[ | ||
"sec-ch-ua", | ||
"\"Not A(Brand\";v=\"99\", \"Google Chrome\";v=\"121\", \"Chromium\";v=\"121\"" | ||
], | ||
[ | ||
"sec-ch-ua-mobile", | ||
"?0" | ||
], | ||
[ | ||
"User-Agent", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" | ||
], | ||
[ | ||
"sec-ch-ua-platform", | ||
"\"macOS\"" | ||
], | ||
[ | ||
"Accept", | ||
"*/*" | ||
], | ||
[ | ||
"Sec-Fetch-Site", | ||
"same-origin" | ||
], | ||
[ | ||
"Sec-Fetch-Mode", | ||
"no-cors" | ||
], | ||
[ | ||
"Sec-Fetch-Dest", | ||
"script" | ||
], | ||
[ | ||
"Referer", | ||
"https://wcjs.sbj.cnipa.gov.cn/sgtmi" | ||
], | ||
[ | ||
"Accept-Encoding", | ||
"gzip, deflate, br, zstd" | ||
], | ||
[ | ||
"Accept-Language", | ||
"zh-CN,zh;q=0.9" | ||
], | ||
[ | ||
"Cookie", | ||
"goN9uW4i0iKzS=60kT8dOgmxXebqEWQEwYEO4TitVQH8CXD6HwieKtCzgFT2IN.iUVh7khPK0REAwDxhcNBIph3t8pLFf5JvsCPl4q; wcjs_cookie=27005561" | ||
] | ||
] | ||
}, | ||
"content": "", | ||
"trailers": null, | ||
"timestamp_start": 1704176297.577336, | ||
"timestamp_end": 1704176297.5777438, | ||
"host": "wcjs.sbj.cnipa.gov.cn", | ||
"port": 443, | ||
"method": "GET", | ||
"scheme": "https", | ||
"authority": "", | ||
"path": "/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js" | ||
}, | ||
"response": { | ||
"http_version": "HTTP/1.1", | ||
"headers": { | ||
"fields": [ | ||
[ | ||
"Date", | ||
"Tue, 02 Jan 2024 06:18:17 GMT" | ||
], | ||
[ | ||
"Content-Type", | ||
"text/javascript; charset=UTF-8" | ||
], | ||
[ | ||
"Content-Length", | ||
"204872" | ||
], | ||
[ | ||
"Connection", | ||
"keep-alive" | ||
], | ||
[ | ||
"Last-Modified", | ||
"Fri, 31 Mar 2023 02:45:25 GMT" | ||
], | ||
[ | ||
"ETag", | ||
"\"64264945-32048\"" | ||
], | ||
[ | ||
"Cache-Control", | ||
"max-age=2592000, public" | ||
], | ||
[ | ||
"Expires", | ||
"Thu, 01 Feb 2024 06:09:07 GMT" | ||
], | ||
[ | ||
"Server", | ||
"NSF" | ||
] | ||
] | ||
}, | ||
"trailers": null, | ||
"timestamp_start": 1704176297.717346, | ||
"timestamp_end": 1704176297.858795, | ||
"status_code": 200, | ||
"reason": "OK" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
.../use-proxy/pysunday-proxy/wcjs.sbj.cnipa.gov.cn/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js/main
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.