Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

nodejs怎么爬post请求?

1、爬虫: nodejs怎么爬ajax的post请求的异步加载的内容?

一个页面异步加载新出的内容怎么抓取?
一般的get请求: www.xxxx.com/page=xxx
get请求可以通过page+1这样加。比如控制页数,抓10页
get异步请求
比如张大妈的发现

http://faxian.smzdm.com/json_more?type=new&timesort=1487861419

通过前几页,替换计算最后一个数字,实现抓取N页情况

2、post方式

而post请求,比如知乎的,一个问题下,‘更多’那个button是个post请求

https://www.zhihu.com/node/QuestionAnswerListV2

post也有url,但是无参数,直接访问可能就404。

我尝试过分析 response返回的 json字符,

{"r":0,
 "msg": (里面是新增的div的html代码,没有规律)
}

3、请问第2点说的post方式有没有办法抓?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

clipboard.png

clipboard.png

这里我使用了request模块、

https://github.com/request/re...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...