File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,24 @@ def _process_problem_data(self, question):
141141 break
142142 prev = prev .previous_element
143143 examples .append (example_dict )
144+
145+ # Fallback: if no <pre> examples found, try <div class="example-block">
146+ if not examples :
147+ example_blocks = soup .find_all ('div' , class_ = 'example-block' )
148+ for i , block in enumerate (example_blocks , 1 ):
149+ # Collect all <p> tags inside the block
150+ block_texts = []
151+ for p in block .find_all ('p' ):
152+ block_texts .append (p .get_text (separator = ' ' , strip = True ))
153+ example_text = '\n ' .join (block_texts )
154+ # Find images inside the block
155+ images = [img ['src' ] for img in block .find_all ('img' ) if img .has_attr ('src' )]
156+ example_dict = {
157+ 'example_num' : i ,
158+ 'example_text' : example_text ,
159+ 'images' : images
160+ }
161+ examples .append (example_dict )
144162 problem_data ['examples' ] = examples
145163
146164 # Extract constraints
You can’t perform that action at this time.
0 commit comments