-
python入门
-
爬虫入门
-
爬虫实践
-
Notes
-
Final
实现了用python模仿知乎登录(urllib,requests)均可实现,后因登录次数过多,需要验证码,所以直接保存了cookie用以登录。对于静态页面的抓取可以用正则表达式或BeautifulSoup库进行匹配抓取合适内容(GrabZhihu、LoginAndJump中均有体现),对于使用js动态加载的,需在分析api后直接对api进行访问,从返回的json中得到所需数据(可参考Request&BeautifulSoup)。最终实现了对于知乎哪张照片让你不由地感叹「年轻,真好」下所有用户头像的抓取,没有保存在本地,仅以<img/>形式保存下来(avatar.html)。
实现了用python爬取知乎某关键字下下全部问题中点赞数过500(可修改)的回答中图片的抓取,同时配合mongoDB将结果存入数据库中。通用性较强,例中关键字为短发,需要修改为其他关键字的可抓包获取加载时api。