您的位置:首页 > 编程语言 > Python开发

pyspider爬虫学习-文档翻译-Script-Environment.md

2017-09-06 00:00 471 查看
摘要: pyspider脚本环境(首次尝试读取源码的同时翻译文档,大家多多指正,勿喷)

Script Environment 脚本环境
==================

Variables 变量
---------
* `self.project_name` #项目名称
* `self.project` information about current project #当前项目信息
* `self.response` #返回
* `self.task` #任务

About Script 关于脚本
------------
#“Handler”的名称并不重要,但是至少需要一个类继承自“BaseHandler”
* The name of `Handler` is not matters, but you need at least one class inherit from `BaseHandler`
#可以设置第三个参数来获得任务对象:“def callback(self,response,task)”
* A third parameter can be set to get task object: `def callback(self, response, task)`
#默认情况下,非200响应不会提交回调。使用“@catch_status_code_error”
* Non-200 response will not submit to callback by default. Use `@catch_status_code_error`

About Environment 关于环境
-----------------
#“日志”、“打印”和异常将被捕获。
* `logging`, `print` and exceptions will be captured.
#您可以通过“from projects import some_project”命令将其他项目作为模块导入
* You can import other projects as module with `from projects import some_project`

### Web view #web视图
#以浏览器(类似)的方式查看页面
* view the page as a browser would render (approximately)

### HTML view #HTML视图
#查看当前回调(index_page、detail_page等等)的HTML
* view the HTML of the current callback (index_page, detail_page, etc.)

### Follows view #遵循视图
#可以从当前进行的回调查看回调
* view the callbacks that can be made from the current callback
#index_page后面的视图将显示可以执行的detail_page回调。
* index_page follows view will show the detail_page callbacks that can be executed.

### Messages view #消息视图
#显示[' self.send_message '](API / self.send_message)API发送的消息。
* shows the messages send by [`self.send_message`](apis/self.send_message) API.

### Enable CSS Selector Helper #使CSS选择器辅助
#启用Web view的CSS选择器助手。它获取您单击的元素的CSS选择器并将其添加到脚本中。
* Enable a CSS Selector Helper of the Web view. It gets the CSS Selector of the element you clicked then add it to your script.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Python PySpider