Enviar pesquisa
Carregar
快快樂樂學 Scrapy
•
Transferir como PPTX, PDF
•
3 gostaram
•
1,613 visualizações
R
recast203
Seguir
Software
Tecnologia
Educação
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 17
Baixar agora
Recomendados
輕輕鬆鬆用 Nodejs 寫網路爬蟲
輕輕鬆鬆用 Nodejs 寫網路爬蟲
傑倫 鍾
Web crawler - Scrapy
Web crawler - Scrapy
yafish
摘星
摘星
zenyuhao
Node分享 展烨
Node分享 展烨
tb-vertical-guide
Node js实践
Node js实践
jay li
Node.js长连接开发实践
Node.js长连接开发实践
longhao
快速入坑 Node.js - 0613 SITCON 雲林定期聚
快速入坑 Node.js - 0613 SITCON 雲林定期聚
Lorex L. Yang
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CI
Chu-Siang Lai
Recomendados
輕輕鬆鬆用 Nodejs 寫網路爬蟲
輕輕鬆鬆用 Nodejs 寫網路爬蟲
傑倫 鍾
Web crawler - Scrapy
Web crawler - Scrapy
yafish
摘星
摘星
zenyuhao
Node分享 展烨
Node分享 展烨
tb-vertical-guide
Node js实践
Node js实践
jay li
Node.js长连接开发实践
Node.js长连接开发实践
longhao
快速入坑 Node.js - 0613 SITCON 雲林定期聚
快速入坑 Node.js - 0613 SITCON 雲林定期聚
Lorex L. Yang
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CI
Chu-Siang Lai
Koa 正在等一個人
Koa 正在等一個人
Fred Chien
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
Yang FaFa
Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)
Chu-Siang Lai
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
Will Huang
Communication with python_http_module
Communication with python_http_module
dreampuf
twMVC#43 C#10 新功能介紹
twMVC#43 C#10 新功能介紹
twMVC
Django入门
Django入门
oikomi
浮云脱水小说站的搭建
浮云脱水小说站的搭建
jondynet
WebConf 2013「Best Practices - The Upload」
WebConf 2013「Best Practices - The Upload」
Orange Tsai
Java_07:Thread
Java_07:Thread
Brad Chao
Node.js從無到有 基本課程
Node.js從無到有 基本課程
Simon Su
Web scraping入門1
Web scraping入門1
兆欽 丘
twMVC#43 YARP
twMVC#43 YARP
twMVC
Banquet 15
Banquet 15
Koubei UED
RxJS 6 新手入門
RxJS 6 新手入門
Will Huang
SQL Server 資料庫版本控管
SQL Server 資料庫版本控管
Will Huang
Tornado开发实践
Tornado开发实践
ZY Zhang
Nginx+常见应用技术指南
Nginx+常见应用技术指南
andy54321
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
Will Huang
课题二:Node.js那些事儿
课题二:Node.js那些事儿
Liu Allen
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
kriszyp
Big data at scrapinghub
Big data at scrapinghub
Dana Brophy
Mais conteúdo relacionado
Mais procurados
Koa 正在等一個人
Koa 正在等一個人
Fred Chien
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
Yang FaFa
Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)
Chu-Siang Lai
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
Will Huang
Communication with python_http_module
Communication with python_http_module
dreampuf
twMVC#43 C#10 新功能介紹
twMVC#43 C#10 新功能介紹
twMVC
Django入门
Django入门
oikomi
浮云脱水小说站的搭建
浮云脱水小说站的搭建
jondynet
WebConf 2013「Best Practices - The Upload」
WebConf 2013「Best Practices - The Upload」
Orange Tsai
Java_07:Thread
Java_07:Thread
Brad Chao
Node.js從無到有 基本課程
Node.js從無到有 基本課程
Simon Su
Web scraping入門1
Web scraping入門1
兆欽 丘
twMVC#43 YARP
twMVC#43 YARP
twMVC
Banquet 15
Banquet 15
Koubei UED
RxJS 6 新手入門
RxJS 6 新手入門
Will Huang
SQL Server 資料庫版本控管
SQL Server 資料庫版本控管
Will Huang
Tornado开发实践
Tornado开发实践
ZY Zhang
Nginx+常见应用技术指南
Nginx+常见应用技术指南
andy54321
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
Will Huang
课题二:Node.js那些事儿
课题二:Node.js那些事儿
Liu Allen
Mais procurados
(20)
Koa 正在等一個人
Koa 正在等一個人
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
Communication with python_http_module
Communication with python_http_module
twMVC#43 C#10 新功能介紹
twMVC#43 C#10 新功能介紹
Django入门
Django入门
浮云脱水小说站的搭建
浮云脱水小说站的搭建
WebConf 2013「Best Practices - The Upload」
WebConf 2013「Best Practices - The Upload」
Java_07:Thread
Java_07:Thread
Node.js從無到有 基本課程
Node.js從無到有 基本課程
Web scraping入門1
Web scraping入門1
twMVC#43 YARP
twMVC#43 YARP
Banquet 15
Banquet 15
RxJS 6 新手入門
RxJS 6 新手入門
SQL Server 資料庫版本控管
SQL Server 資料庫版本控管
Tornado开发实践
Tornado开发实践
Nginx+常见应用技术指南
Nginx+常见应用技术指南
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
课题二:Node.js那些事儿
课题二:Node.js那些事儿
Destaque
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
kriszyp
Big data at scrapinghub
Big data at scrapinghub
Dana Brophy
Scrapy.for.dummies
Scrapy.for.dummies
Chandler Huang
Scrapy
Scrapy
Francisco Sousa
XPath for web scraping
XPath for web scraping
Scrapinghub
Downloading the internet with Python + Scrapy
Downloading the internet with Python + Scrapy
Erin Shellman
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
Anton
Mining legal texts with Python
Mining legal texts with Python
Flávio Codeço Coelho
Python, web scraping and content management: Scrapy and Django
Python, web scraping and content management: Scrapy and Django
Sammy Fung
電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞
Andy Dai
均一Gae甘苦談
均一Gae甘苦談
蘇 倚恩
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
Solution4Future
Web backends development using Python
Web backends development using Python
Ayun Park
如何用 grs 擷取台灣上市股票股價資訊 PyCon APAC 2014
如何用 grs 擷取台灣上市股票股價資訊 PyCon APAC 2014
Toomore
Learn REST API with Python
Learn REST API with Python
Larry Cai
Visualising Data with Code
Visualising Data with Code
Ri Liu
Web Scraping in Python with Scrapy
Web Scraping in Python with Scrapy
orangain
Developing RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDB
Nicola Iarocci
Destaque
(18)
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
Big data at scrapinghub
Big data at scrapinghub
Scrapy.for.dummies
Scrapy.for.dummies
Scrapy
Scrapy
XPath for web scraping
XPath for web scraping
Downloading the internet with Python + Scrapy
Downloading the internet with Python + Scrapy
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
Mining legal texts with Python
Mining legal texts with Python
Python, web scraping and content management: Scrapy and Django
Python, web scraping and content management: Scrapy and Django
電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞
均一Gae甘苦談
均一Gae甘苦談
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
Web backends development using Python
Web backends development using Python
如何用 grs 擷取台灣上市股票股價資訊 PyCon APAC 2014
如何用 grs 擷取台灣上市股票股價資訊 PyCon APAC 2014
Learn REST API with Python
Learn REST API with Python
Visualising Data with Code
Visualising Data with Code
Web Scraping in Python with Scrapy
Web Scraping in Python with Scrapy
Developing RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDB
Semelhante a 快快樂樂學 Scrapy
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
MarsZ Chen
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
Yanwei Liu
Git安裝
Git安裝
Hong Da Lin
Linux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
Kenny (netman)
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
Laird Cheng
前端工程師一定要知道的 Docker 虛擬化容器技巧
前端工程師一定要知道的 Docker 虛擬化容器技巧
Chu-Siang Lai
02.python.开发最佳实践
02.python.开发最佳实践
Na Lee
使用Supervisor守护python进程
使用Supervisor守护python进程
果 果
Linuxguide4f2e
Linuxguide4f2e
tb-vertical-guide
LinuxGuide4F2E
LinuxGuide4F2E
sodabiscuit
GNU Autoconf / Automake #1
GNU Autoconf / Automake #1
imacat .
Android系统移植技术详解
Android系统移植技术详解
zzc89522
Python的module机制与最佳实践
Python的module机制与最佳实践
Leo Zhou
Puppet安装总结
Puppet安装总结
Yiwei Ma
Ruby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for Mac
MarsZ Chen
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
Bo-Yi Wu
141118 Raspberry Pi 電鈴工作坊@松山文創園區
141118 Raspberry Pi 電鈴工作坊@松山文創園區
CAVEDU Education
Pipi pi
Pipi pi
Matthew Lien
Python包管理工具介绍
Python包管理工具介绍
Young King
Graphlab Create使用說明,以SFrame為例
Graphlab Create使用說明,以SFrame為例
Simon Li
Semelhante a 快快樂樂學 Scrapy
(20)
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
Git安裝
Git安裝
Linux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
前端工程師一定要知道的 Docker 虛擬化容器技巧
前端工程師一定要知道的 Docker 虛擬化容器技巧
02.python.开发最佳实践
02.python.开发最佳实践
使用Supervisor守护python进程
使用Supervisor守护python进程
Linuxguide4f2e
Linuxguide4f2e
LinuxGuide4F2E
LinuxGuide4F2E
GNU Autoconf / Automake #1
GNU Autoconf / Automake #1
Android系统移植技术详解
Android系统移植技术详解
Python的module机制与最佳实践
Python的module机制与最佳实践
Puppet安装总结
Puppet安装总结
Ruby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for Mac
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
141118 Raspberry Pi 電鈴工作坊@松山文創園區
141118 Raspberry Pi 電鈴工作坊@松山文創園區
Pipi pi
Pipi pi
Python包管理工具介绍
Python包管理工具介绍
Graphlab Create使用說明,以SFrame為例
Graphlab Create使用說明,以SFrame為例
快快樂樂學 Scrapy
1.
h4353062@hotmail.com 鍾怡傑
2.
甚麼是 Scrapy
? 如何安裝 ? Go! Go! 開始吧~ 實作第一個 Spider Demo
3.
Scrapy 是一個
Python 的框架,可以簡單用 Python 的程式碼寫網路蜘蛛,很方便的抓網頁上 的資料。 Scrapy at a glance Frequently Asked Questions
4.
需要安裝 ◦ Python
2.7 ◦ Lxml ◦ OpenSSL ◦ pip or easy_install 安裝 Scrapy ◦ pip install Scrapy ◦ or ◦ easy_install Scrapy http://doc.scrapy.org/en/latest/intro/install.html
5.
Step 1. 編輯
/etc/apt/sources.list 加入這行 deb http://archive.scrapy.org/ubuntu precise main 2. 執行 curl –s http://archive.scrapy.org/ubuntu/archive.key | sudo apt-key add – 3. 升級 sudo apt-get update 4. 安裝 sudo apt-get install scrapy-<Version> 5. 測試執行 scrapy 指令 http://doc.scrapy.org/en/latest/topics/ubuntu.html
6.
7.
http://doc.scrapy.org/en/latest/topics/architecture.html
8.
甚麼是 Scrapy
Shell ? ◦ 一個 python 的直譯器,可以動態顯示執行的結果。 執行 scrapy shell “<URL>” Ex: scrapy shell "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/"
9.
讓我們試一下吧~ 觀察輸出的結果 In
[1]: sel.xpath('//title') In [2]: sel.xpath('//title').extract() In [3]: sel.xpath('//title/text()') In [4]: sel.xpath('//title/text()').extract() In [5]: sel.xpath('//title/text()').re('(w+):')
10.
由輸出結果可知,Scrapy 使用
Xpath 語法抓網頁的資 訊,預設輸出使用 JSON 格式 對於 Xpath 語法不熟的話,可參考以下網址: 1. http://www.w3schools.com/XPath/ 2. http://msdn.microsoft.com/zh- tw/library/ms256086(v=vs.110).aspx 練習資源 1. Xpath Tester 2. Chrome 瀏覽器的 Xpath Helper 套件
11.
Scrapy Tutorial
12.
基本流程: 1. 建立一個新
Scrapy 專案 2. 定義你需要的 Item 3. 寫一個 Spider 抓資料 4. 寫一個 Item Pipeline 存抓到的資料
13.
scrapy startproject
<Project_Name> scrapy startproject tutorial tutorial/ ├── tutorial │ ├── __init__.py │ ├── items.py │ ├── pipelines.py │ ├── settings.py │ └── spiders │ └── __init__.py └── scrapy.cfg
14.
編輯 tutorial/tutorial/items.py from
scrapy.item import Item, Field class DmozItem(Item): title = Field() link = Field() desc = Field()
15.
編輯 tutorial/tutorial/spiders/dmoz_spider.py from
scrapy.spider import Spider from scrapy.selector import Selector from tutorial.items import DmozItem class DmozSpider(Spider): name = “dmoz” allowed_domains = ["dmoz.org"] start_urls = [ “http://www.dmoz.org/Computers/Programming/Languages/Python/B "http://www.dmoz.org/Computers/Programming/Languages/Python/R ] def parse(self, response): sel = Selector(response) sites = sel.xpath('//ul/li') items = [] for site in sites: item = DmozItem() #之前 Step2 定義的 Item item['title'] = site.xpath('a/text()').extract() item['link'] = site.xpath('a/@href').extract() item['desc'] = site.xpath('text()').extract() items.append(item) return items
16.
執行路徑必須在 tutorial/tutorial/spiders/
抓到的資料儲存在 spiders/items.json scrapy crawl dmoz -o items.json -t json
17.
參考資料: Scrapy 0.22
documentation
Baixar agora