项目作者: iHealth-ecnu

项目描述 :
iHealth 项目的内容爬虫(一个基于 python 和 MongoDB 的医疗咨询爬虫)
高级语言: Python
项目地址: git://github.com/iHealth-ecnu/iHealth_crawler.git
创建时间: 2017-11-01T02:29:42Z
项目社区:https://github.com/iHealth-ecnu/iHealth_crawler

开源协议:GNU General Public License v2.0

关键词:
lxml pymongo python requests

下载


iHealth_crawler

iHealth 项目的内容爬虫

TODO

安装依赖

  • requests
  • pymongo
  • lxml

MongoDB 配置

  1. 开启 MongoDB 权限认证:在配置文件中加入 auth = true

  2. 创建管理员用户(如果你是第一次使用 MongoDB)

    1. use admin
    2. db.createUser({user:"admin",pwd:"admin123",roles:["userAdminAnyDatabase"]})

    管理员用户用来创建其他数据库和用户

  3. 使用管理员账户远程登录

    1. C:\Users\cs>mongo [your_ip]:27017
    2. > use admin
    3. switched to db admin
    4. > db.auth('admin','admin123')
    5. 1
  4. 创建 iHealth 数据库,以及操作该数据库的用户

    1. use iHealth // 创建数据库,并作为认证数据库
    2. db.createUser({
    3. user:'admin', // 用户名
    4. pwd:'admin123', // 用户密码
    5. roles:[{role:'readWrite',db:'iHealth'}] // 为该用户赋予数据库的读写权限
    6. })
  5. 使用该用户远程登录 iHealth 数据库

    1. C:\Users\cs>mongo [your_ip]:27017
    2. > use iHealth
    3. switched to db iHealth
    4. > db.auth('admin','admin123')
    5. 1
    6. > db.getCollectionNames()
    7. [ ]

    数据库刚刚创建,所以没有数据

启动说明

  1. 安装环境:Python 环境和依赖 + MongoDB 配置

  2. 配置 common.py 中的数据库信息

    1. # 数据库配置
    2. mongo_dbname = 'iHealth'
    3. mongo_host = 'your_ip' # mongodb 主机地址
    4. mongo_port = 27017 # mongodb 主机端口
    5. mongo_user = 'your_user' # mongodb 登陆用户
    6. mongo_pwd = 'your_password' # mongodb 用户密码
  3. 运行

    • Windows :
      1. python iHealth_crawler.py
    • Linux :
      1. sh server.sh start

注意

  • 脚本功能:
    • server.sh:启动/停止/重启/查看状态/查看日志 heatbox 服务,用法:
      1. Usages: sh server.sh [start|stop|restart|status|log]

参考资料