Learning Scrapy 笔记(1)

一、Scrapy 简介

Scrapy是Python开发的一个快速,高层次的屏幕抓取和web抓取框架,用于抓取web站点并从页面中提取结构化的数据。它的优势在于它是一个框架,任何人可以根据需求方便进行更改。

二、HTML 和 XPath

在学习爬虫之前,我们需要先对网站的结构有一些基本的了解。

从输入网址(或点击一个链接)到网页在浏览器中呈现出来需要4个步骤:

1. 将URL输入给浏览器。URL的第一部分(域名,比如gumtree.com)是用来在web上找到对应的服务器。该URL以及一其他数据,(例如cookie)形成发送到该服务器的请求。

2. 服务器返回一个HTML页面给浏览器。要注意一些服务器也许会返回其它格式,比如XML,JSON...现在只考虑HTML。

3. HTML被浏览器转换成一个内部树表示,通常叫做:Document Object Model(DOM)。

4. 基于一些布局规则,内部表示最终被呈现为在屏幕上看到的视觉表示。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Paperback: 270 pages Publisher: Packt Publishing - ebooks Account (January 30, 2016) Language: English ISBN-10: 1784399787 ISBN-13: 978-1784399788 Key Features Extract data from any source to perform real time analytics. Full of techniques and examples to help you crawl websites and extract data within hours. A hands-on guide to web scraping and crawling with real-life problems and solutions Book Description This book covers the long awaited Scrapy v 1.0 that empowers you to extract useful data from virtually any source with very little effort. It starts off by explaining the fundamentals of Scrapy framework, followed by a thorough description of how to extract data from any source, clean it up, shape it as per your requirement using Python and 3rd party APIs. Next you will be familiarised with the process of storing the scrapped data in databases as well as search engines and performing real time analytics on them with Spark Streaming. By the end of this book, you will perfect the art of scarping data for your applications with ease What you will learn Understand HTML pages and write XPath to extract the data you need Write Scrapy spiders with simple Python and do web crawls Push your data into any database, search engine or analytics system Configure your spider to download files, images and use proxies Create efficient pipelines that shape data in precisely the form you want Use Twisted Asynchronous API to process hundreds of items concurrently Make your crawler super-fast by learning how to tune Scrapy's performance Perform large scale distributed crawls with scrapyd and scrapinghub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值