File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -725,6 +725,24 @@ class InputCallbacks(object):
725
725
CATCH_EXCEPTIONS = (Exception ,)
726
726
DEFAULT_RETURN = NotSet
727
727
728
+ @classmethod
729
+ def use_content_for_default_callbacks (cls , ** kwargs ):
730
+ cls ._CALLBACKS .update (
731
+ {
732
+ 'json' : lambda text , context : GlobalConfig .json_loads (context [
733
+ 'resp' ].content ),
734
+ 'se' : lambda text , context : _lib .HTMLParser (context ['resp' ].
735
+ content ),
736
+ 'selectolax' : lambda text , context : _lib .HTMLParser (context [
737
+ 'resp' ].content ),
738
+ 'css' : lambda text , context : _lib .BeautifulSoup (
739
+ context ['resp' ].content , 'lxml' ),
740
+ 'html' : lambda text , context : _lib .BeautifulSoup (
741
+ context ['resp' ].content , 'lxml' ),
742
+ 'xml' : lambda text , context : _lib .BeautifulSoup (
743
+ context ['resp' ].content , 'lxml-xml' )
744
+ }, ** kwargs )
745
+
728
746
@classmethod
729
747
def callback (cls , text , context , callback_name = None ):
730
748
try :
You can’t perform that action at this time.
0 commit comments