一、微信公众号爬虫思路:html
参考:记一次微信公众号爬虫的经历python
二、scrapy框架图git
三、scrapy经典教程github
参考:mongodb
四、其它chrome
参考:shell
一、环境的安装django
MongoDB:微信
mongodb的安装与启动cookie
具体命令以下:
python链接MongoDB,需安装pip install mongoengine
启动:
sudo ./mongod --port 27017 dbpath "/software/mongodb-4.0.0/data/db" --logpath "/software/mongodb-4.0.0/log/mongodb.log" --logappend --replSet rs0
Windows下MongoDB数据导出:
mongodump --port 27017 -d wechat -o D:\MongoDB
Linux下MongoDB数据导入:
./mongorestore -h 127.0.0.1 --port 27017 -d wechat --drop /software/mongodb-4.0.0/wechat
数据导入时注意:
Do you run mongo in replica set, i.e., mongod --replSet rs0?
If yes, please remember to run in your mongo shell the command: rs.initiate()
参考:
二、cookie获取
selenium进行登陆验证,保存cookies,为scrapy作准备。
三、爬虫
参考:
scrapy爬虫利用selenium实现用户登陆和cookie传递
四、django调用爬虫
五、django构建搜索引擎,搜索爬过的信息
参考:
环境配置:
elasticsearch-rtf安装、pip install mongo-connector、pip install mongo-connector[elastic5]、pip install elastic2-doc-manager
MongoDB数据同步到elasticsearch:
mongo-connector -m localhost:27017 -t localhost:9200 -d elastic2_doc_manager
一、selenium在新页面定位元素问题
参考:
解决Selenium弹出新页面没法定位元素问题(Unable to locate element)
Selenium Webdriver元素定位的八种经常使用方式
三、在管道中关闭爬虫
spider.crawler.engine.close_spider(spider, 'bandwidth_exceeded')