Scrapy+BeautifulSoup+MongoDB 高效能資料採集方案(Chapter 1st)

來源:互聯網
上載者:User

標籤:成功   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)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.