惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
博客园 - 聂微东
小众软件
小众软件
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
罗磊的独立博客
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
S
Security @ Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
月光博客
月光博客
S
Secure Thoughts
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
W
WeLiveSecurity
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
L
LangChain Blog
T
The Blog of Author Tim Ferriss
NISL@THU
NISL@THU
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Project Zero
Project Zero
SecWiki News
SecWiki News
爱范儿
爱范儿
The Register - Security
The Register - Security
AI
AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
L
Lohrmann on Cybersecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
J
Java Code Geeks
S
Securelist
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog

博客园 - 莫耶

学习RxJS:Cycle.js 学习RxJS: 导入 [Node.js] Node.js项目的持续集成 [Node.js] 使用node-forge保障Javascript应用的传输安全 [Node.js] 对称加密、公钥加密和RSA [Node.js] DSL in action [Node.js] 使用TypeScript编写Node项目 [Node.js] Node.js中的流 [Node.js] 基于Socket.IO 的私聊 [Node.js] 闭包和高阶函数 [Node.js] Promise,Q及Async [Node.js] Express的测试覆盖率 [Node.js] BDD和Mocha框架 [Node.js] 也说this [Node.js] ECMAScript 6中的生成器及koa小析 [Node.js] 使用File API 异步上传文件 [Node.js] OAuth 2 和 passport框架 [Node.js] Node + Redis 实现分布式Session方案 [Node.js] Cluster,把多核用起来
Python开源框架Scrapy安装及使用
莫耶 · 2014-03-15 · via 博客园 - 莫耶

2014-03-15 16:21  莫耶  阅读(1278)  评论()    收藏  举报

一、安装问题
环境: CentOS  + Python 2.7 + Pip

1) 安装时遇到 ”UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9” 错误,安装libffi-devel 和 Python-devel:

yum install libffi-devel
yum install python-devel

2) 安装 lxml 时 遇到错误,可能是缺少 libxml2-devel 和 libxslt-devel,使用yum安装:
yum install libxslt-devel libxml2-devel

3) 遇到 bz2 错误,则需要:
yum install bzip2-devel

4) 安装 Twisted 时遇到解压错误,需要先手动将twisted 包当下来,自行解压进行安装:
cd ~
wget http://pypi.python.org/packages/source/T/Twisted/Twisted-13.2.0.tar.bz2
tar xjvf Twisted-13.2.0.tar.bz2 
cd Twisted-13.2.0
python2.7 setup.py install     
然后使用 pip 安装 Scrapy:
pip2.7 install Scrapy

二、中文乱码问题
先安装一个chardet:
pip2.7 install chardet

在程序中判断一下输入并转码输出:

text = response.body
content_type = chardet.detect(text)
if content_type['encoding'] != 'UTF-8':
        text = text.decode(content_type['encoding'])
text = text.encode('utf-8')

Creative Commons License