We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2b76e81 commit 2adc60eCopy full SHA for 2adc60e
leetcode_scraper.py
@@ -141,6 +141,24 @@ def _process_problem_data(self, question):
141
break
142
prev = prev.previous_element
143
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)
162
problem_data['examples'] = examples
163
164
# Extract constraints
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments