| 8 | |
| 9 | |
| 10 | class SplashResponseTypes(ResponseTypes): |
| 11 | CLASSES = { |
| 12 | 'text/html': 'scrapy_splash.response.SplashTextResponse', |
| 13 | 'application/atom+xml': 'scrapy_splash.response.SplashTextResponse', |
| 14 | 'application/rdf+xml': 'scrapy_splash.response.SplashTextResponse', |
| 15 | 'application/rss+xml': 'scrapy_splash.response.SplashTextResponse', |
| 16 | 'application/xhtml+xml': 'scrapy_splash.response.SplashTextResponse', |
| 17 | 'application/vnd.wap.xhtml+xml': 'scrapy_splash.response.SplashTextResponse', |
| 18 | 'application/xml': 'scrapy_splash.response.SplashTextResponse', |
| 19 | 'application/json': 'scrapy_splash.response.SplashJsonResponse', |
| 20 | 'application/x-json': 'scrapy_splash.response.SplashJsonResponse', |
| 21 | 'application/javascript': 'scrapy_splash.response.SplashTextResponse', |
| 22 | 'application/x-javascript': 'scrapy_splash.response.SplashTextResponse', |
| 23 | 'text/xml': 'scrapy_splash.response.SplashTextResponse', |
| 24 | 'text/*': 'scrapy_splash.response.SplashTextResponse', |
| 25 | } |
| 26 | |
| 27 | def from_args(self, headers=None, url=None, filename=None, body=None): |
| 28 | """Guess the most appropriate Response class based on |
| 29 | the given arguments.""" |
| 30 | cls = super(SplashResponseTypes, self).from_args( |
| 31 | headers=headers, |
| 32 | url=url, |
| 33 | filename=filename, |
| 34 | body=body |
| 35 | ) |
| 36 | if cls is Response: |
| 37 | cls = scrapy_splash.SplashResponse |
| 38 | return cls |
| 39 | |
| 40 | |
| 41 | responsetypes = SplashResponseTypes() |