mirror of
https://github.com/pysunday/sdenv.git
synced 2025-04-05 01:03:51 +08:00
fix: 1. windows系统兼容;2. 文档补充;3. 文件删减
This commit is contained in:
parent
09f7e3d17b
commit
ab6eb3fd10
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
output/
|
||||
!example/use-local/output/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.idea
|
||||
@ -10,3 +11,4 @@ yarn.lock
|
||||
.history
|
||||
*.swp
|
||||
build/
|
||||
*.node
|
||||
|
40
README.md
40
README.md
@ -1,5 +1,5 @@
|
||||
<h1 align="center">
|
||||
<img width="100" height="100" src="logo.svg" alt=""><br>
|
||||
<img width="100" height="100" src="logo.png" alt=""><br>
|
||||
sdenv
|
||||
</h1>
|
||||
|
||||
@ -10,22 +10,38 @@ sdenv是一个javascript运行时补环境框架,与github上其它补环境
|
||||
|
||||
## 依赖
|
||||
|
||||
作者开发时使用的是`v20.10.0`版本node,预期最低要求是18版本,由于未做其它版本可用性测试,因此建议使用sdenv的node版本大于等于`v20.10.0`
|
||||
作者开发时使用的是`v20.10.0`版本node,预期最低要求是18版本,由于未做其它版本可用性测试,因此建议使用sdenv的node版本大于等于`v20.10.0`。
|
||||
|
||||
## 安装
|
||||
|
||||
由于`document.all`需要由c代码动态生成,而固定编译环境下的编译产物只能在相同编译环境下运行,因此安装sdenv后需要动态编译生成node文件
|
||||
|
||||
1. 安装:`npm i sdenv`
|
||||
2. 编译c代码:`cd node_modules/sdenv && yarn build`
|
||||
|
||||
**在编译过程未实现自动化之前可直接clone项目使用**
|
||||
编译node插件用的是[node-gyp](https://github.com/nodejs/node-gyp)工具,该工具需要有python环境和c环境(如windows系统需安装Visual Studio),请根据工具文档进行系统环境搭建。
|
||||
|
||||
## 使用
|
||||
|
||||
### 源码方式
|
||||
|
||||
1. clone项目:`git clone https://github.com/pysunday/sdenv.git`
|
||||
2. 安装依赖:`cd sdenv && npm i`
|
||||
3. 执行编译,unix运行:`npm run build`,windows运行:`npm run build:win`
|
||||
4. 运行样例:
|
||||
* [运行本地代码](https://github.com/pysunday/sdenv/blob/main/example/use-local/README.md):`node example/use-local/index.js`
|
||||
* [运行网站代码](https://github.com/pysunday/sdenv/blob/main/example/use-remote/README.md):`node example/use-remote/index.js`
|
||||
|
||||

|
||||
|
||||
### npm包方式
|
||||
|
||||
1. 安装npm包:`npm i sdenv`
|
||||
2. 进入文件夹`node-modules/sdenv`执行编译,unix运行:`npm run build`,windows运行:`npm run build:win`
|
||||
3. 导入包方法:
|
||||
```javascript
|
||||
const browser = require('sdenv/browser/');
|
||||
const { jsdomFromText, jsdomFromUrl } = require('sdenv/utils/jsdom');
|
||||
```
|
||||
|
||||
### 样例代码
|
||||
|
||||
因为项目核心功能基于jsdom,且jsdom对dom的实现非常完善,因此使用sdenv之前建议有一定html与javascript语言开发基础,然后参考example目录下的样例文件:
|
||||
|
||||
1. [use-local](https://github.com/pysunday/sdenv/example/use-local/README.md)
|
||||
1. 运行本地代码:[use-local](https://github.com/pysunday/sdenv/example/use-local/README.md)
|
||||
```javascript
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@ -75,7 +91,7 @@ sdenv是一个javascript运行时补环境框架,与github上其它补环境
|
||||
|
||||
loadPages()
|
||||
```
|
||||
2. [use-remote](https://github.com/pysunday/sdenv/example/use-remote/README.md)
|
||||
2. 运行网站代码:[use-remote](https://github.com/pysunday/sdenv/example/use-remote/README.md)
|
||||
```javascript
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
|
||||
const logger = require('../../utils/logger');
|
||||
|
Binary file not shown.
@ -4,8 +4,22 @@ output目录是使用[rs-reverse](https://github.com/pysunday/rs-reverse)下载
|
||||
|
||||
会用到三个文件:
|
||||
|
||||
1. 网页html:`output/makecode_input_html.html`
|
||||
1. 网页html(主要用到dom结构,内部js代码内容不会执行):`output/makecode_input_html.html`
|
||||
2. 网页中的js外链:`output/makecode_input_js.js`
|
||||
3. 网页中提取的$_ts:`output/makecode_input_ts.json`
|
||||
3. 网页中提取的$_ts(从html页面中提取):`output/makecode_input_ts.json`
|
||||
|
||||
当然不用rs-reverse工具也可自己下载对应文件(如商标局网站):
|
||||
|
||||
```bash
|
||||
1. 下载html和js文件
|
||||
wget -O output/makecode_input_html.html https://商标局/sgtmi
|
||||
wget -O output/makecode_input_js.js https://商标局/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js
|
||||
2. 复制并保存html网页中的$_ts内容到output/makecode_input_ts.json
|
||||
{
|
||||
"nsd": "html页面的$_ts.nsd值",
|
||||
"cd": "html页面的$_ts.cd值"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
文件存在后执行命令`node example/use-local/index.js`生成cookie。
|
||||
|
9
example/use-local/output/makecode_input_html.html
Normal file
9
example/use-local/output/makecode_input_html.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta content="nMHVqmrXqt7pfGxC9d5Qn7GsapHQlUKq" r="m"><!--[if lt IE 9]><script r='m'>document.createElement("section")</script><![endif]--><script type="text/javascript" r='m'>$_ts=window['$_ts'];if(!$_ts)$_ts={};$_ts.nsd=35801;$_ts.cd="qxfqrrAloaEqcs3EDGAbcqEqDGEFqS93qGqeqpLDDpGFrrLmHqaErrLFxS9drAEqDG3FrS93DGERHnAFqp9dqfLDkq9lhrLqDsZPDGlbcqEqDGQFrr93qGqFxpLkDpGcqrLrDG3RDqEqDPWFrp93rGVWcGA2DGqRHaV2qrLoDGARDqEqDGEFqS93HA3RHaWcqrLlDGVREq3mkcnRqsVSrAVnHR9OoTFplmo2Bed.AdlcOdJzPj9wTdUCTfQ5BMtGJaHueoqkrkAorqb3hqqHUvabHHVzQ9ykAoTm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w9w1f_ePeaRC9.wCdfh6rnRcz6IBZBQoJPt6wa_Pe6RoQ.QDOOh6w73nza3He2h6mjwUR7e6QBQUTuto6zR1euwbWLI5Nah6JCQcfdgKQBQbNf3PUXMDYOJnzuRiZBwDf9t6JL4ne0wU3.IDB0h6zTFczZR8LB8C2CInfS_bZBIKf.toiT8KNTtKR03.YuMCSCQnfG_KEkrAVkKn64WaWrKPJG3N9oUclfVGAJSPwjYAVmWsjRqsEerA3TcRGn";if($_ts.lcd)$_ts.lcd();</script><script type="text/javascript" charset="utf-8" src="/c5rxzYrjRT2h/cCdzB9ZjDFks.294cc83.js" r='m'></script></head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript" r='m'>_$aH();</script>
|
3
example/use-local/output/makecode_input_js.js
Normal file
3
example/use-local/output/makecode_input_js.js
Normal file
File diff suppressed because one or more lines are too long
1
example/use-local/output/makecode_input_ts.json
Normal file
1
example/use-local/output/makecode_input_ts.json
Normal file
@ -0,0 +1 @@
|
||||
{"nsd":35801,"cd":"qxfqrrAloaEqcs3EDGAbcqEqDGEFqS93qGqeqpLDDpGFrrLmHqaErrLFxS9drAEqDG3FrS93DGERHnAFqp9dqfLDkq9lhrLqDsZPDGlbcqEqDGQFrr93qGqFxpLkDpGcqrLrDG3RDqEqDPWFrp93rGVWcGA2DGqRHaV2qrLoDGARDqEqDGEFqS93HA3RHaWcqrLlDGVREq3mkcnRqsVSrAVnHR9OoTFplmo2Bed.AdlcOdJzPj9wTdUCTfQ5BMtGJaHueoqkrkAorqb3hqqHUvabHHVzQ9ykAoTmC0NPsUW6WOdkJ2xDRcV5VBwCMC9NFUm2e1ezQD2.tDI7MCZNF6xLRMYzwb2NKPG.LmpEpTlaVlMpJYmWFmZaUty_MCrtpP3uabTCFK9.FvuTMne.QDzLxIwCMC9NFUm2e1ezQD2.K1K4ibR639TSpdyF1UReF2z2eb96Qvqdw1XOKDTaFK7LR5SBMn2.Qbf2zKTCFK9.FvuTMne.QDz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KPJG3N9oUclfVGAJSPwjYAVmWsjRqsEerA3TcRGn","metaContent":"nMHVqmrXqt7pfGxC9d5Qn7GsapHQlUKq"}
|
@ -9,7 +9,8 @@
|
||||
"scripts": {
|
||||
"test": "jest ./test/",
|
||||
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand ./test/",
|
||||
"build": "node-gyp rebuild && cp build/Release/*.node ./bin/",
|
||||
"build": "node-gyp rebuild && cp build/Release/documentAll.node ./bin/",
|
||||
"build:win": "node-gyp rebuild && copy .\\build\\Release\\documentAll.node .\\bin\\",
|
||||
"release": "release-it"
|
||||
},
|
||||
"logLevel": "debug",
|
||||
|
BIN
static/example.png
Normal file
BIN
static/example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 KiB |
Loading…
Reference in New Issue
Block a user