python之路 -- 爬蟲 -- Scrapy入門

來源:互聯網
上載者:User

標籤:ide   site   nbsp   code   pipe   items   分享圖片   pipeline   install   

Scrapy

  Scrapy 是一個為了爬取網站資料,提取結構性資料而編寫的應用程式框架。 其可以應用在資料採礦,資訊處理或儲存曆史資料等一系列的程式中。
其最初是為了頁面抓取 (更確切來說, 網路抓取 )所設計的, 也可以應用在擷取API所返回的資料(例如 Amazon Associates Web Services ) 或者通用的網路爬蟲。Scrapy用途廣泛,可以用於資料採礦、監測和自動化測試。

下面是Scrapy的架構,包括組件以及在系統中發生的資料流的概覽(綠色箭頭所示)。

 

 資料流

 Scrapy中的資料流由執行引擎控制,其過程如下:

 

Scarpy的安裝

 1 安裝: 2 Linux/mac 3     - pip3 install scrapy  4 Windows: 5     - 安裝twsited 6         a. pip3 install wheel 7         b. 下載twisted http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 8         c. 進入下載目錄,執行 pip3 install Twisted-xxxxx.whl 9     - 安裝scrapy 10         d. pip3 install scrapy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com11     - 安裝pywin3212         e. pip3 install pywin32  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 Scarpy的基本使用

 建立項目:

scrapy startproject tutorial#該命令將會建立一個新的Scarpy項目

得到:

tutorial/    scrapy.cfg            # 項目的設定檔    tutorial/             # 該項目的python模組。之後您將在此加入代碼        __init__.py        items.py          # 項目中的item檔案        pipelines.py      # 項目中的pipelines檔案        settings.py       # 項目的設定檔案        spiders/          # 放置spider代碼的目錄            __init__.py

 

python之路 -- 爬蟲 -- Scrapy入門

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.