標籤:成功 nop 建立 bom scrapy soft obj dir art
運行環境 CentOS7.3 + Python2.7 + Scrapy1.3 + MongoDB3.4 + BeautifulSoup4.6編程工具 PyCharm + Robomongo + Xshell請確保你的 python版本為2.7.5以上 版本
強烈推薦直接【翻 牆 安 裝】,簡單輕鬆yum install gcc libffi-devel python-devel openssl-develpip install scrapy
如果提示以下錯誤AttributeError: ‘module‘ object has no attribute ‘OP_NO_TLSv1_1‘說明你的 Twisted 版本過高,請執行pip install Twisted==16.4.1
然後再安裝以下內容pip install "ScrapyMongoDB"pip install beautifulsoup4pip install pymongo然後執行scrapy startproject fusnion就可以建立一個名為 funsion 的項目附錄A:Scrapy Shell 調試Linux 命令列下輸入(以本網站為例)scrapy shell ‘http://www.cnblogs.com/funsion/‘進入互動式shell,輸入以下內容
>>> from bs4 import BeautifulSoup >>> soup = BeautifulSoup(response.body)>>> print soup.title如果能輸出 <title>Funsion Wu - 部落格園</title> 則代表成功附錄B:參考文檔Scrapy官方中文文檔 http://scrapy-chs.readthedocs.org/zh_CN/latest/index.htmlBeautifulSoup 中文手冊 http://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.htmlScrapy Mongo 說明文檔 https://github.com/noplay/scrapy-mongodb附錄C:mongodb安裝方法tar /usr/local/src/mongodb-linux-x86_64-rhel62-3.4.4.tgzcd /usr/local/src/mongodb-linux-x86_64-rhel62-3.4.4mkdir -p /data/{mongodb_data,mongodb_log}/usr/local/src/mongodb-linux-x86_64-rhel62-3.4.4/bin/mongod --dbpath=/data/mongodb_data --logpath=/data/mongodb_log/mongodb.log --logappend --fork &ln -s /usr/local/src/mongodb-linux-x86_64-rhel62-3.4.4/bin/mongo /usr/local/bin/mongo編輯/etc/rc.local,加入下述代碼然後再儲存即可。/usr/local/src/mongodb-linux-x86_64-rhel62-3.4.4/bin/mongod --dbpath=/data/mongodb_data --logpath=/data/mongodb_log/mongodb.log --logappend --fork &
Scrapy+BeautifulSoup+MongoDB 高效能資料採集方案(Chapter 1st)