Windows下安装Scrapy

一、 Scrapy简介

Scrapy is a fast high-level screen scraping and web crawling framework, used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing.

官方主页: http://www.scrapy.org/


二、 安装Python2.7


官方主页:http://www.python.org/

下载地址:http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi


1) 安装python

安装目录:D:\Program\Python273
 
2) 添加环境变量

系统属性 -> 高级 -> 环境变量 - >系统环境变量 -> Path -> Edit
在系统环境变量里添加";D:\Program\Python273;D:\Program\Python273\Scripts",注意前边的分号
注意很多教程里只添加了"D:\Program\Python273",在后边可能会发生输入scrapy命令时提示找不到目标的情况,因此一并添加

3) 验证Python

C:\Users\Jeffee>python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win 32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit


三、 安装Twisted

Twisted is an event-driven networking engine written in Python and licensed under the open source

1) 安装setuptools

Download, build, install, upgrade, and uninstall Python packages -- easily!

官方主页:http://pypi.python.org/pypi/setuptools

下载地址:http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe

安装过程:略


2) 安装Zope.Interface

官方主页:http://pypi.python.org/pypi/zope.interface/

下载地址:http://pypi.python.org/packages/2.7/z/zope.interface/zope.interface-4.0.1-py2.7-win32.egg

安装过程:

C:\Users\Jeffee>d:
D:\>cd Program\Python273\Scripts
D:\Program\Python273\Scripts>easy_install.exe zope.interface-4.0.1-py2.7-win32.egg
Processing zope.interface-4.0.1-py2.7-win32.egg
creating d:\python27\lib\site-packages\zope.interface-4.0.1-py2.7-win32.egg
Extracting zope.interface-4.0.1-py2.7-win32.egg to d:\python27\lib\site-packages
Adding zope.interface 4.0.1 to easy-install.pth file

Installed d:\Program\Python273\lib\site-packages\zope.interface-4.0.1-py2.7-win32.egg
Processing dependencies for zope.interface==4.0.1
Finished processing dependencies for zope.interface==4.0.1
D:\>cd Program\Python273\Scripts

验证安装


D:\Program\Python273\Scripts>python
Python 2.7.3 (default, Apr 11 2014, 21:03:47) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope.interface
>>>


3) 安装Twisted

官方主页:http://twistedmatrix.com/trac/wiki/TwistedProject

下载地址:https://pypi.python.org/packages/2.7/T/Twisted/
根据需要选择32位或者64位

安装过程:略

 四、 安装w3lib

官方主页:http://pypi.python.org/pypi/w3lib

下载地址: http://pypi.python.org/packages/source/w/w3lib/w3lib-1.2.tar.gz

解压过程:略

安装命令
python setup.py install
 
 在python环境中使用
>>> import w3lib
未报错则成功


五、 安装libxml2

官方主页:http://users.skynet.be/sbi/libxml-python/http://pypi.python.org/pypi/pyOpenSSL

下载地址:http://users.skynet.be/sbi/libxml-python/binaries/libxml2-python-2.7.7.win32-py2.7.exe

安装过程:略

安装之后检测时会报错:


D:\Program\install>python
Python 2.7.3 (default, Apr 11 2014, 21:24:47) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
Traceback (most recent call last):
  File "
   
   
    
    ", line 1, in 
    
    
     
     
  File "D:\Program\Python273\lib\site-packages\libxml2.py", line 1, in 
     
     
      
      
    from libxmlmods import libxml2mod
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。

     
     
    
    
   
   


错误显示:ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。
解决办法:安装64位的插件,部分64位的插件可以在下面这个网站上找到:http://www.lfd.uci.edu/~gohlke/pythonlibs/#libxml-python
根据Pthon的版本,需要下载安装libxml2-python-2.9.1.win-amd64-py2.7.exe
执行,未报错

 六、 安装pyOpenSSL

官方主页:http://pypi.python.org/pypi/pyOpenSSL

下载地址:https://pypi.python.org/packages/2.7/p/pyOpenSSL/

选择自己需要的版本

安装过程:略

验证安装:
 在python环境中使用
>>> import OpenSSL
未报错则成功


七、 安装Scrapy

官方主页:http://scrapy.org/

下载地址:http://pypi.python.org/packages/source/S/Scrapy/Scrapy-0.14.4.tar.gz

解压过程:略

验证安装:

T:\>scrapy
Scrapy 0.14.4 - no active project

Usage:
  scrapy  [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

Use "scrapy  -h" to see more info about a command

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值