zpc@Lenovo-PC:/prj/pyscrapy/a$ scrapy startproject helloword
New Scrapy project 'helloword' created in:
    /cygdrive/e/01.prj/pyscrapy/a/helloword

You can start your first spider with:
    cd helloword
    scrapy genspider example example.com

 

zpc@Lenovo-PC:/prj/pyscrapy/a/helloword$ scrapy genspider baidu www.baidu.com
Created spider 'baidu' using template 'basic' in module:
  helloword.spiders.baidu

 

问题:


zpc@Lenovo-PC:/prj/pyscrapy/a/tutorial$ scrapy crawl dmoz
/cygdrive/e/01.prj/pyscrapy/a/tutorial/tutorial/spiders/dmoz_spider.py:3: ScrapyDeprecationWarning: tutorial.spiders.dmoz_spider.DmozSpider inherits from deprecated class scrapy.spider.BaseSpider, please inherit from scrapy.spider.Spider. (warning only on first subclass, there may be others)
  class DmozSpider(BaseSpider):
2014-12-17 11:32:38+0000 [scrapy] INFO: Scrapy 0.24.4 started (bot: tutorial)
2014-12-17 11:32:38+0000 [scrapy] INFO: Optional features available: ssl, http11
2014-12-17 11:32:38+0000 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'tutorial.spiders', 'SPIDER_MODULES': ['tutorial.spiders'], 'BOT_NAME': 'tutorial'}
2014-12-17 11:32:40+0000 [scrapy] INFO: Enabled extensions: LogStats, TelnetConsole, CloseSpider, WebService, CoreStats, SpiderState
2014-12-17 11:32:41+0000 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2014-12-17 11:32:41+0000 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2014-12-17 11:32:41+0000 [scrapy] INFO: Enabled item pipelines:
2014-12-17 11:32:41+0000 [dmoz] INFO: Spider opened
2014-12-17 11:32:41+0000 [dmoz] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2014-12-17 11:32:41+0000 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2014-12-17 11:32:41+0000 [scrapy] DEBUG: Web service listening on 127.0.0.1:6080


 

iconv [选项...] [文件...]
有如下选项可用:
输入/输出格式规范:
-f, --from-code=名称 原始文本编码
-t, --to-code=名称 输出编码
信息:
-l, --list 列举所有已知的字符集
输出控制:
-c 从输出中忽略无效的字符
-o, --output=FILE 输出文件
-s, --silent 关闭警告
--verbose 打印进度信息

iconv -f utf-8 -t gb2312 /server_test/reports/software_.txt > /server_test/reports/software_asserts.txt

 

URL encode decode

http://kb.cnblogs.com/page/133765/

 

(1) url编码:

import urllib

url = 'http://test.com/s?wd=哈哈'

url = url.decode('gbk', 'replace')

print urllib.quote(url.encode('utf-8', 'replace'))

结果: http%3a%2f%2ftest.com%2fs%3fwd%3d%e5%93%88%e5%93%88

(2) url解码:

import urllib

encoded_url = 'http%3a%2f%2ftest.com%2fs%3fwd%3d%e5%93%88%e5%93%88'

print urllib.unquote(encoded_url).decode('utf-8', 'replace').encode('gbk', 'replace')

 

 

http://blog.csdn.net/yelbosh/article/details/7551584

 

很好的资料(必看(自))

http://blog.javachen.com/2014/05/24/using-scrapy-to-cralw-data/

 

求救:  使用git clone时, 出现以下错误如何解决?
aaa$ git clone https://github.com/python-excel/xlwt.git
Cloning into 'xlwt'...
/usr/libexec/git-core/git-remote-https.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

zpc@Lenovo-PC:/usr/libexec/git-core$ gdb /usr/libexec/git-core/git-remote-https.exe
(gdb) r
Starting program: /usr/libexec/git-core/git-remote-https.exe
[New Thread 3192.0x19d0]
gdb: unknown target exception 0xc0000135 at 0x77898f05
During startup program exited with code 0xc0000135.

 

 

http://blog.csdn.net/hjy_six/article/details/6862648

 

Windows和cygwin路径的转换

cygwin下的cd命令可以直接使用Windows的路径表示。

注:不要忘了加上单引号,因为\是bash元字符,用于转义。不用上单引号cd命令收到的参数值就不是C:\Windows\System32\drivers\etc,运行报错。

$cygpath -aw '/cygdrive/c/Windows/System32/drivers/etc'

C:\Windows\System32\drivers\etc

$cygpath -au 'C:\Windows\System32\drivers\etc'

/cygdrive/c/Windows/System32/drivers/etc

cygpath命令来完成转换,相关的选项是:

-a, --absolute        output absolute path

-w, --windows         print Windows form of NAMEs (C:\WINNT)

-u, --unix            (default) print Unix form of NAMEs (/cygdrive/c/winnt)

 

查看浏览器的user-agent

javascript:alert(navigator.userAgent)
firefox
 

# -*- encoding: gb2312 -*-

import  codecs, sys

#  用codecs提供的open方法来指定打开的文件的语言编码,它会在读取的时候自动转换为内部unicode

bfile  =  codecs.open( " dddd.txt " ,  ' r ' ,  " big5 " )

# bfile = open("dddd.txt", 'r')

ss  =  bfile.read()

bfile.close()

 

VIM正则表达式

http://www.cnblogs.com/RigorosLee/archive/2011/05/13/2045806.html

 

使用lxml前注意事项:先确保html经过了utf-8解码,即code = html.decode('utf-8', 'ignore'),否则会出现解析出错情况。因为中文被编码成utf-8之后变成 '/u2541' 之类的形式,lxml一遇到 “/”就会认为其标签结束。

 

scrapy命令相关

不显示无用的log

scrapy crawl --nolog test

FIRST SCRAPY PRJ的更多相关文章

  1. Scrapy框架爬虫初探——中关村在线手机参数数据爬取

    关于Scrapy如何安装部署的文章已经相当多了,但是网上实战的例子还不是很多,近来正好在学习该爬虫框架,就简单写了个Spider Demo来实践.作为硬件数码控,我选择了经常光顾的中关村在线的手机页面 ...

  2. scrapy爬虫docker部署

    spider_docker 接我上篇博客,为爬虫引用创建container,包括的模块:scrapy, mongo, celery, rabbitmq,连接https://github.com/Liu ...

  3. scrapy 知乎用户信息爬虫

    zhihu_spider 此项目的功能是爬取知乎用户信息以及人际拓扑关系,爬虫框架使用scrapy,数据存储使用mongo,下载这些数据感觉也没什么用,就当为大家学习scrapy提供一个例子吧.代码地 ...

  4. ubuntu 下安装scrapy

    1.把Scrapy签名的GPG密钥添加到APT的钥匙环中: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 6272 ...

  5. 网络爬虫:使用Scrapy框架编写一个抓取书籍信息的爬虫服务

      上周学习了BeautifulSoup的基础知识并用它完成了一个网络爬虫( 使用Beautiful Soup编写一个爬虫 系列随笔汇总 ), BeautifulSoup是一个非常流行的Python网 ...

  6. Scrapy:为spider指定pipeline

    当一个Scrapy项目中有多个spider去爬取多个网站时,往往需要多个pipeline,这时就需要为每个spider指定其对应的pipeline. [通过程序来运行spider],可以通过修改配置s ...

  7. scrapy cookies:将cookies保存到文件以及从文件加载cookies

    我在使用scrapy模拟登录新浪微博时,想将登录成功后的cookies保存到本地,下次加载它实现直接登录,省去中间一系列的请求和POST等.关于如何从本次请求中获取并在下次请求中附带上cookies的 ...

  8. Scrapy开发指南

    一.Scrapy简介 Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中. Scrapy基于事件驱动网络框架 Twis ...

  9. 利用scrapy和MongoDB来开发一个爬虫

    今天我们利用scrapy框架来抓取Stack Overflow里面最新的问题(),并且将这些问题保存到MongoDb当中,直接提供给客户进行查询. 安装 在进行今天的任务之前我们需要安装二个框架,分别 ...

随机推荐

  1. HyperLedger Fabric 1.4 区块链技术形成(1.2)

    在比特币诞生之时,没有区块链技术概念,当人们看到比特币在无中心干预的前提下,还能安全.可靠的运行,比特币网络打开了人们的想象空间:技术专家们开始研究比特币的底层技术,并抽象提取出来,形成区块链技术,或 ...

  2. python基础之内置函数补充、匿名函数、递归函数

    内置函数补充 python divmod()函数:把除数和余数运算结果结合起来,返回一个包含商和余数的元组(a // b, a % b) 语法: 1 divmod(a, b) #a.b为数字,a为除数 ...

  3. 【转】正则表达式速查表(http://www.jb51.net/shouce/jquery1.82/regexp.html)

    正则表达式速查表 字符 描述 \ 将下一个字符标记为一个特殊字符.或一个原义字符.或一个向后引用.或一个八进制转义符.例如,“n”匹配字符“n”.“\n”匹配一个换行符.串行“\\”匹配“\”而“\( ...

  4. CSS的z-index & 绝对定位与相对定位

    1.在有些情况下,需要仔细地控制元素在网页中堆叠顺序.z-index样式属性让你能够设置元素的堆叠顺序. 堆叠元素时,z-index值较大的元素在z-index值较小的下面. 2.z-index值仅在 ...

  5. Windows下zookeeper注册中心的安装和启动

    zookeeper的安装支持单机模式和集群模式 下载地址:http://www.apache.org/dyn/closer.cgi/zookeeper/,当前稳定版本为3.4.8 单机模式 修改zoo ...

  6. laravel5.5artisan命令

    目录 1. 简介 2. 编写命令 2.1 构建自己的命令 2.2 闭包命令 3. 定义输入期望 4.I/O 命令 5. 注册命令 6. 调用命令 1. 简介 Artisan 是 Laravel 自带的 ...

  7. java 解析/读取 种子/bt/torrent 内容

    碰到不会的技术问题,我还是先度娘.能中文看懂,为什么非要看英文呢. java 解析/读取 种子/bt/torrent  内容,这个度娘给的满意答案并不是很多.GG之后的搜索结果出现了stackover ...

  8. ITIBB原创,互联网首部自媒体小说《1024伐木累》-小白篇之入职-总章节一

    小序 IT人不懂爱?代码汪是小白?又有谁,懂我情怀? 逗比青年,背上行囊,懵懵懂懂闯帝都!前途似海,来日方长! 青春无梦妄少年!认定就作,不平就说,碰撞火花,如此绚烂…… IT人有比格?其实,那是顽强 ...

  9. 剑指Offer - 九度1508 - 把字符串转换成整数

    剑指Offer - 九度1508 - 把字符串转换成整数2014-02-06 23:46 题目描述: 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数. 输入: 输入可能包含多个测试样例 ...

  10. [18/12/3]蓝桥杯 练习系统 入门级别 Fibonacci数列求模问题 题解思路

    前言略. 看到这个题目本来应该很高兴的,因为什么,因为太TM的基础了啊! 可是当你用常规方法尝试提交OJ时你会发现..hhh...运行超时..(开心地摇起了呆毛 //Fibonacci数列递归一般问题 ...