导航:首页 > 编程语言 > pythonscapy下载

pythonscapy下载

发布时间:2022-07-17 09:02:57

⑴ scapy怎么将响应与请求对应

先去https://pypi.python.org/pypi/scapy/2.3.1网址中下载安装包
在ubuntu下安装,解压缩之后,在相应路径下执行python setup.py install此时即可使用scapy模块!

⑵ python安装scrapy,所需要安装的包都安装好了,但是在最后安装scrapy时,老是出现错误

这个问题已经困扰我好几天了。。。大兄弟后面是怎么解决这个问题的?

⑶ python3.6安装Scrapy出现以下错误怎么解决

scapy安装的错误有几种类型。 因为网络限制,你无法自动下载依赖的库 因为版本冲突问题,导致你安装scapy时无法完成安装,或者是安装无法正确使用 因为编译的位数不同64位和32位不同,

⑷ 如何python 中运行scapy shell

启用shell
可以使用如下命令启用shell
[python] view plain
scrapy shell <url>
其中<url>就是你想抓取的页面url

使用shell
Scrapy shell可以看成是一个内置了几个有用的功能函数的python控制台程序。

功能函数
shelp() - 输出一系列可用的对象和函数
fetch(request_or_url)-从给定的url或既有的request请求对象重新生成response对象,并更新原有的相关对象
view(response)-使用浏览器打开原有的response对象(换句话说就是html页面)
Scrapy 对象
使用Scrapy shell下载指定页面的时候,会生成一些可用的对象,比如Response对象和Selector对象(Html和XML均适用)
这些可用的对象有:

crawler - 当前的Crawler对象
spider
request - 最后获取页面的请求对象
response - 一个包含最后获取页面的响应对象
sel - 最新下载页面的Selector对象
settings - 当前的Scrapy settings
Scrapy shell例子
以我的个人博客作为测试:http://blog.csdn.net/php_fly
首先,我们启动shell
[python] view plain
scrapy shell http://blog.csdn.net/php_fly --nolog
以上命令执行后,会使用Scrapy downloader下载指定url的页面数据,并且打印出可用的对象和函数列表

[python] view plain
[s] Available Scrapy objects:
[s] crawler <scrapy.crawler.Crawler object at 0x0000000002AEF7B8>
[s] item {}
[s] request <GET http://blog.csdn.net/php_fly>
[s] response <200 http://blog.csdn.net/php_fly>
[s] sel <Selector xpath=None data=u'<html xmlns="http://www.w3.org/1999/xhtm'>
[s] settings <CrawlerSettings mole=None>
[s] spider <Spider 'default' at 0x4cdb940>
[s] Useful shortcuts:
[s] shelp() Shell help (print this help)
[s] fetch(req_or_url) Fetch request (or URL) and update local objects
[s] view(response) View response in a browser
获取曾是土木人博客的文章列表超链接
[python] view plain
In [9]: sel.xpath("//span[@class='link_title']/a/@href").extract()
Out[9]:
[u'/php_fly/article/details/19364913',
u'/php_fly/article/details/18155421',
u'/php_fly/article/details/17629021',
u'/php_fly/article/details/17619689',
u'/php_fly/article/details/17386163',
u'/php_fly/article/details/17266889',
u'/php_fly/article/details/17172381',
u'/php_fly/article/details/17171985',
u'/php_fly/article/details/17145295',
u'/php_fly/article/details/17122961',
u'/php_fly/article/details/17117891',
u'/php_fly/article/details/14533681',
u'/php_fly/article/details/13162011',
u'/php_fly/article/details/12658277',
u'/php_fly/article/details/12528391',
u'/php_fly/article/details/12421473',
u'/php_fly/article/details/12319943',
u'/php_fly/article/details/12293587',
u'/php_fly/article/details/12293381',
u'/php_fly/article/details/12289803']
修改scrapy shell的请求方式:

[python] view plain
>>> request = request.replace(method="POST")
>>> fetch(request)
[s] Available Scrapy objects:
[s] crawler <scrapy.crawler.Crawler object at 0x1e16b50>
...

从Spider中调用Scrapy shell
在爬虫运行过程中,有时需要检查某个响应是否是你所期望的。
这个需求可以通过scrapy.shell.inspect_response函数进行实现
以下是一个关于如何从spider中调用scrapy shell的例子

[python] view plain
from scrapy.spider import Spider

class MySpider(Spider):
name = "myspider"
start_urls = [
"http://example.com",
"http://example.org",
"http://example.net",
]

def parse(self, response):
# We want to inspect one specific response.
if ".org" in response.url:
from scrapy.shell import inspect_response
inspect_response(response)

# Rest of parsing code.
当你启动爬虫的时候,控制台将打印出类似如下的信息
[python] view plain
2014-02-20 17:48:31-0400 [myspider] DEBUG: Crawled (200) <GET http://example.com> (referer: None)
2014-02-20 17:48:31-0400 [myspider] DEBUG: Crawled (200) <GET http://example.org> (referer: None)
[s] Available Scrapy objects:
[s] crawler <scrapy.crawler.Crawler object at 0x1e16b50>
...
>>> response.url
'http://example.org'
注意:当Scrapy engine被scrapy shell占用的时候,Scrapy shell中的fetch函数是无法使用的。 然而,当你退出Scrapy shell的时候,蜘蛛将从停止的地方继续爬行

⑸ 求教python程序调用scapy模块的问题

你把python27.dll复制成python27_d.dll就可以了。然后把dll放到windows/system32目录。或者是程序执行目录中。 原因是你的程序是debug版本的。你编译成release版本就没有这个问题了。 你编译能成功可见python27的lib应该连接成了。

⑹ python,scapy,rdpcap模块缺失问题

你可以参考一下:

Python 2.7.3 (default, Apr 10 2013, 05:09:49)
[GCC 4.7.2] on linux2
Type "help", "right", "credits" or "license" for more information.
>>> from scapy.all import *
WARNING: No route found for IPv6 destination :: (no default route?)
>>> IP()
<IP |>
>>> target="ww w.b ai.c om"
>>> target="ww w.d u.co m/30"
>>> ip=IP(dst=target)
>>> ip
<IP dst=Net('ww w.ba i.c om/30') |>
>>> [p for p in ip]
[<IP dst=61.135.169.104 |>, <IP dst=61.135.169.105 |>, <IP dst=61.135.169.106 |>, <IP dst=61.135.169.107 |>]
>>>

⑺ 如何在centos中安装pythonscapy

在CentOs6.5下安装Python2.7.6和Scrapy
总在网上看大家的安装教程,这回自己也贡献一份!!!
和民航大学合作项目,去给人家装环境,连简单的Scrapy都没装上,虽然有对方硬件设施坑爹的因素,但主要还是自己准备不充分。
一份好的安装文档应该是可以完美重现的。
所以做了下面这份:
我按照这套方法连着重装了四次,如果各位直接复制命令,应该是一点问题都没有。安装成功的样子见那两张截图。
对了,确保电脑能上网,鼠标能用,哈哈
1.#su – root
2.#yum install gcc zlib-devel bzip2-devel openssl-devel ncurses-devel libffi-devel libxslt-devel libxml2-devel sqlite-devel
3.#cd /usr
4.安装Python
#wget python/2.7.6/Python-2.7.6.tar.xz
#xz -d Python-2.7.6.tar.xz
#tar xvf Python-2.7.6.tar
#cd Python-2.7.6
#./configure
#vim Moles/Setup
找到下面这句,去掉注释
#zlib zlibmole.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
编译安装:make & make install
5.修改Python链接
#/usr/local/bin/python2.7 -V
#mv /usr/bin/python /usr/bin/python.bak
# ln -s /usr/local/bin/python2.7 /usr/bin/python
6.#vim /usr/bin/yum
在打开的文件里的头一行,也就是指定python环境的那行代码,修改成:
#!/usr/bin/python2.6
7.#wget --no-check-certificate
#python ez_setup.py
8.#wget --no-check-certificate
#python get-pip.py
9.#pip install scrapy
10.#scrapy
11.建立测试脚本
12.# cat > myspider.py <<EOF
from scrapy import Spider, Item, Field
class Post(Item):
title = Field()
class BlogSpider(Spider):
name, start_urls = 'blogspider', ['wsblog/']
def parse(self, response):
return [Post(title=e.extract()) for e in response.css("h2 a::text")]
EOF

13.试建工程
scrapy startproject tutorial

⑻ Python安装Scrapy出现以下错误怎么办

scapy安装的错误有几种类型。
因为网络限制,你无法自动下载依赖的库
因为版本冲突问题,导致你安装scapy时无法完成安装,或者是安装无法正确使用
因为编译的位数不同64位和32位不同,导致的问题

解决办法:
简单的解决办法。如果scrapy对你很重要。重新安装一套python2.7然后从头安装scrapy,可以从pypi网站上下载。也可以从unofficial来源,一口气安装好的包。

耐心的解决办法。把scrapy的源码拿过来,执行python setup.py install,遇到哪个包不好用,就替换掉。办法是将那个包的源代码拿过来,先删除site-packages里的相应包,再手工执行python setup.py install。要有心理准备,很可能需要vc++ 2010的编译器。

最简单的办法,使用pip install scrapy。 如果你是在ubuntu下面apt-get install python-scrapy就搞定了。

阅读全文

与pythonscapy下载相关的资料

热点内容
男主是鸭子女主是大老板 浏览:562
日批的小说 浏览:578
周香允参与过所有的电影 浏览:926
红羊出品有哪些 浏览:398
14路末班车电影陈明辉结局 浏览:977
金庸小说全集下载 浏览:792
美国电影主角和老师偷情 浏览:132
成人两性微电影 浏览:408
台湾三级的绝版老电影 浏览:161
电影双男主肉 浏览:986
重生之北美建国 浏览:129
每天工作4小时的程序员 浏览:462
香港学生犯罪电影 浏览:869
0855aa 浏览:506
哪里买小电影软件 浏览:857
无法连接服务器上不了怎么处理 浏览:251
android怎样读 浏览:617
螺纹底经算法 浏览:783
西门子plc编程官网 浏览:612
宝宝吃进口燕窝溯源码 浏览:320