python 爬虫 中国专利公布公告

目标网站:
python 爬虫 中国专利公布公告
首先看一下请求
python 爬虫 中国专利公布公告
带全参数模拟发送一下请求
python 爬虫 中国专利公布公告
可以拿到html但是没有链接地址,链接地址应该是点击操作后,执行zl_pp这个函数生成的

全文搜索一下zl_pp,发现在isearch.js这个文件里
python 爬虫 中国专利公布公告
贴出来调试一下
python 爬虫 中国专利公布公告
根据他的逻辑,首先他获得了id为pato的这个元素。去原html搜索下,发现是个表单python 爬虫 中国专利公布公告
找一下提交表单的这个请求
python 爬虫 中国专利公布公告
目测刚刚那段js代码就是生成一些参数,然后填到这个表单里post提交,代码不长,直接改写一下
python 爬虫 中国专利公布公告
先做个表单的框架,再将其他逻辑改写下
python 爬虫 中国专利公布公告
调试一下看看
python 爬虫 中国专利公布公告
获得表单数据
python 爬虫 中国专利公布公告
在同一地址尝试发起post请求
python 爬虫 中国专利公布公告
发现返回了加密js
python 爬虫 中国专利公布公告
研究一下结构,
python 爬虫 中国专利公布公告
里面有3个meta标签
python 爬虫 中国专利公布公告
python 爬虫 中国专利公布公告

3个script标签,其中一个script中放的是加密代码
python 爬虫 中国专利公布公告
格式化一下加密代码

===============================================================================
此时就没什么思路了,把这段代码放到调试工具中,发现并不能直接运行,会报各种少东西
网上找了参考文章:https://segmentfault.com/a/1190000017541235

根据他的思路先找到参数列表
python 爬虫 中国专利公布公告
关于替换原文中混淆字符串的工具,原文中使用了acorn,但是我没找到详细的资料,后来我搜AST,发现了这篇文章
https://segmentfault.com/a/1190000016231512
里面推荐了一个类似的工具recast,并且有详细使用方法