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

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.

转载于:https://my.oschina.net/sijinge/blog/1529897

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值