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.
相关文章推荐
- pyspider爬虫学习-文档翻译-Deployment.md
- pyspider爬虫学习-文档翻译-index.md
- pyspider爬虫学习-文档翻译-Architecture.md
- pyspider爬虫学习-文档翻译-Command-Line.md
- pyspider爬虫学习-文档翻译-About-Tasks.md
- pyspider爬虫学习-文档翻译-About-Projects.md
- pyspider爬虫学习-文档翻译-Frequently-Asked-Questions.md
- pyspider爬虫学习-文档翻译-Working-with-Results.md
- pyspider爬虫学习-API-self.crawl.md
- pyspider爬虫学习-教程3-Render-with-PhantomJS.md
- pyspider爬虫学习-教程2-AJAX-and-more-HTTP.md
- pyspider爬虫学习-API-self.send_message.md
- pyspider爬虫学习-API-Response.md
- pyspider爬虫学习-教程1-HTML-and-CSS-Selector.md
- 开始学习、翻译android文档
- Android Geofence的学习(一)翻译官方文档
- db4o_8.0对象数据库官方文档翻译_学习笔记一
- Hibernate学习英文文档翻译 4.3.11 总览
- Apache Drill学习文档尝试翻译之Parquet格式数据转换