File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1231,9 +1231,9 @@ async def crawl(
1231
1231
get_delayed_content = None ,
1232
1232
)
1233
1233
1234
- elif url .startswith ("raw:" ) or url . startswith ( "raw://" ) :
1234
+ elif url .startswith ("raw:" ):
1235
1235
# Process raw HTML content
1236
- raw_html = url [4 :] if url [: 4 ] == "raw:" else url [7 :]
1236
+ raw_html = url [6 :] if url . startswith ( "raw://" ) else url [4 :]
1237
1237
html = raw_html
1238
1238
if config .screenshot :
1239
1239
screenshot_data = await self ._generate_screenshot_from_html (html )
Original file line number Diff line number Diff line change 15
15
if not CRAWL4AI_HOME_DIR .joinpath ("profiles" , "test_profile" ).exists ():
16
16
CRAWL4AI_HOME_DIR .joinpath ("profiles" , "test_profile" ).mkdir (parents = True )
17
17
18
+ @pytest .fixture
19
+ def basic_html ():
20
+ return """
21
+ <html lang="en">
22
+ <head>
23
+ <title>Basic HTML</title>
24
+ </head>
25
+ <body>
26
+ <h1>Main Heading</h1>
27
+ <main>
28
+ <div class="container">
29
+ <p>Basic HTML document for testing purposes.</p>
30
+ </div>
31
+ </main>
32
+ </body>
33
+ </html>
34
+ """
35
+
18
36
# Test Config Files
19
37
@pytest .fixture
20
38
def basic_browser_config ():
@@ -325,6 +343,13 @@ async def test_stealth_mode(crawler_strategy):
325
343
)
326
344
assert response .status_code == 200
327
345
346
+ @pytest .mark .asyncio
347
+ @pytest .mark .parametrize ("prefix" , ("raw:" , "raw://" ))
348
+ async def test_raw_urls (crawler_strategy , basic_html , prefix ):
349
+ url = f"{ prefix } { basic_html } "
350
+ response = await crawler_strategy .crawl (url , CrawlerRunConfig ())
351
+ assert response .html == basic_html
352
+
328
353
# Error Handling Tests
329
354
@pytest .mark .asyncio
330
355
async def test_invalid_url ():
You can’t perform that action at this time.
0 commit comments