首页 > 代码库 > Windows下安装Scrapy

Windows下安装Scrapy

这几天正好有需求实现一个爬虫程序,想到爬虫程序立马就想到了python,python相关的爬虫资料好像也特别多。于是就决定用python来实现爬虫程序了,正好发现了python有一个开源库scrapy,正是用来实现爬虫框架的,于是果断采用这个实现。下面就先安装scrapy,决定在windows下面安装。

 

Scrapy简介

Scrapy是一个快速,高效的网页抓取python框架。主要用于Web抓取&提取信息&格式化数据。经常用此做数据挖掘、检测、测试等。

安装所需软件

  • python
  • python
  • python

安装步骤

1、安装Python
官网下载python(http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi),双击msi文件即可直接安装, 将python路径(D:\Python27;D:\Python27\Scripts;)加入环境变量 
验证是否安装ok
C:\Users\admin>pythonPython 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>>
2、安装setuptools
官网下载setuptools(http://pypi.python.org/pypi/setuptools),可以下载相关的ez_setup.py文件,然后直接执行该文件即能自动完成安装:
python  ez_setup.py
3、安装Zope.Interface
官网下载Zope.Interface(http://pypi.python.org/pypi/zope.interface/)到官网下载与python版本对应的安装文件msi文件,双击也可以自动完成安装,验证是否安装ok
C:\Users\admin>pythonPython 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import zope.interface>>>
4、安装Twisted
官网下载Twisted(http://twistedmatrix.com/trac/wiki/Downloads)下载对应版本的msi文件,双击直接安装即可。
5、安装w3lib
官网下载w3lib(http://pypi.python.org/pypi/w3lib) 安装,下载w3lib-1.9.0.tar.gz文件,解压,
#进入插件目录并执行命令安装>D:\python-plugin\w3lib-1.3>python setup.py install

验证

D:\python-plugin\w3lib-1.3>pythonPython 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import w3lib>>>
6、安装libxml2
官网下载libxml2(http://users.skynet.be/sbi/libxml-python/)& 下载对应python版本的exe文件,双击即可
7、安装pyOpenSSL
官网下载pyOpenSSL(https://pypi.python.org/pypi/pyOpenSSL)& 傻瓜安装
8、安装scrapy
官网下载scrapy(https://pypi.python.org/pypi/Scrapy) 安装
#进入scrapy目录并执行安装>D:\python-plugin\Scrapy-0.16.5>python setup.py install

验证

D:\python-plugin\Scrapy-0.16.5>scrapyScrapy 0.16.5 - no active projectUsage:  scrapy <command> [options] [args]Available commands:  fetch         Fetch a URL using the Scrapy downloader  runspider     Run a self-contained spider (without creating a project)  settings      Get settings values  shell         Interactive scraping console  startproject  Create new project  version       Print Scrapy version  view          Open URL in browser, as seen by Scrapy  [ more ]      More commands available when run from project directoryUse "scrapy <command> -h" to see more info about a commandD:\python-plugin\Scrapy-0.16.5>

安装完毕 OK