MCPcopy
hub / github.com/scrapy/scrapy / from_mimetype

Method from_mimetype

scrapy/responsetypes.py:51–58  ·  view source on GitHub ↗

Return the most appropriate Response class for the given mimetype

(self, mimetype: str)

Source from the content-addressed store, hash-verified

49 self.classes[mimetype] = load_object(cls)
50
51 def from_mimetype(self, mimetype: str) -> type[Response]:
52 """Return the most appropriate Response class for the given mimetype"""
53 if mimetype is None:
54 return Response
55 if mimetype in self.classes:
56 return self.classes[mimetype]
57 basetype = f"{mimetype.split('/', maxsplit=1)[0]}/*"
58 return self.classes.get(basetype, Response)
59
60 def from_content_type(
61 self, content_type: str | bytes, content_encoding: bytes | None = None

Callers 7

from_content_typeMethod · 0.95
from_filenameMethod · 0.95
from_bodyMethod · 0.95
download_requestMethod · 0.80

Calls 1

getMethod · 0.45

Tested by 3