dmzj漫画保存(6)
2023-03-16 来源:你乐谷
可以看到在输入文字时有一些xhr文件
在按下enter键之后
可以看到跟前面文章中百度搜索不一样,搜索实现是用的post方法,那么只要把要搜的名称发送给服务器即可得到对应页面
分析到这一步就可以开始着手代码编写实现了
实现
首先是最麻烦的网址解密,也就是要执行网页上的js代码
这里要使用python的pyexecjs库格式如下教程参考
pre class=line-numbers language-pythoncode class= language-pythonspan class=token keywordimport/span execjsspan class=token comment# eval 和 complie 是要构建一个JS的环境/spane span class=token operator=/span execjsspan class=token punctuation./spanspan class=token builtineval/spanspan class=token punctuation(/spanspan class=token stringa = new Array(1,2,3)/spanspan class=token punctuation)/spanspan class=token comment# 可以直接执行JS代码/spanspan class=token keywordprint/spanspan class=token punctuation(/spanespan class=token punctuation)/spanx span class=token operator=/span execjsspan class=token punctuation./spanspan class=token builtincompile/spanspan class=token punctuation(/spanspan class=token triple-quoted-string stringfunction add(x,y){return x y;};/spanspan class=token punctuation)/spanspan class=token keywordprint/spanspan class=token punctuation(/spanxspan class=token punctuation./spancallspan class=token punctuation(/spanspan class=token stringadd/spanspan class=token punctuation,/span span class=token string1/spanspan class=token punctuation,/span span class=token string2/spanspan class=token punctuation)/spanspan class=token punctuation)/spanspan class=token comment# execjs@66152.compile用于执行更复杂的js代码/spanspan class=token comment# 运行结果:
在按下enter键之后
可以看到跟前面文章中百度搜索不一样,搜索实现是用的post方法,那么只要把要搜的名称发送给服务器即可得到对应页面
分析到这一步就可以开始着手代码编写实现了
实现
首先是最麻烦的网址解密,也就是要执行网页上的js代码
这里要使用python的pyexecjs库格式如下教程参考
pre class=line-numbers language-pythoncode class= language-pythonspan class=token keywordimport/span execjsspan class=token comment# eval 和 complie 是要构建一个JS的环境/spane span class=token operator=/span execjsspan class=token punctuation./spanspan class=token builtineval/spanspan class=token punctuation(/spanspan class=token stringa = new Array(1,2,3)/spanspan class=token punctuation)/spanspan class=token comment# 可以直接执行JS代码/spanspan class=token keywordprint/spanspan class=token punctuation(/spanespan class=token punctuation)/spanx span class=token operator=/span execjsspan class=token punctuation./spanspan class=token builtincompile/spanspan class=token punctuation(/spanspan class=token triple-quoted-string stringfunction add(x,y){return x y;};/spanspan class=token punctuation)/spanspan class=token keywordprint/spanspan class=token punctuation(/spanxspan class=token punctuation./spancallspan class=token punctuation(/spanspan class=token stringadd/spanspan class=token punctuation,/span span class=token string1/spanspan class=token punctuation,/span span class=token string2/spanspan class=token punctuation)/spanspan class=token punctuation)/spanspan class=token comment# execjs@66152.compile用于执行更复杂的js代码/spanspan class=token comment# 运行结果: