crawl4ai icon indicating copy to clipboard operation
crawl4ai copied to clipboard

[Bug]: css_selector can only select the first class in the page

Open zhongxinlei opened this issue 7 months ago • 1 comments

crawl4ai version

Version: 0.5.0.post8

Expected Behavior

CSS Selector Example

async def simple_example_with_css_selector(): print("\n--- Using CSS Selectors ---") browser_config = BrowserConfig(headless=True) crawler_config = CrawlerRunConfig( cache_mode=CacheMode.BYPASS, css_selector="li.CommitRow-module__ListItem_0--PkFAi h4" )

async with AsyncWebCrawler(config=browser_config) as crawler:
    result = await crawler.arun(
        url="https://github.com/microsoft/TypeScript/commits/main", config=crawler_config
    )
    print("Partial HTML length:", len(result.cleaned_html))

this code can only result in the first commit, there 35 commits in the page

Current Behavior

CSS Selector Example

async def simple_example_with_css_selector(): print("\n--- Using CSS Selectors ---") browser_config = BrowserConfig(headless=True) crawler_config = CrawlerRunConfig( cache_mode=CacheMode.BYPASS, css_selector="li.CommitRow-module__ListItem_0--PkFAi h4" )

async with AsyncWebCrawler(config=browser_config) as crawler:
    result = await crawler.arun(
        url="https://github.com/microsoft/TypeScript/commits/main", config=crawler_config
    )
    print("Partial HTML length:", len(result.cleaned_html))

can only receive the first commit, there 35 commits in the page

Is this reproducible?

Yes

Inputs Causing the Bug


Steps to Reproduce


Code snippets


OS

Linux Ubuntu 24.04

Python version

3.12

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

No response

zhongxinlei avatar May 03 '25 04:05 zhongxinlei

update to version Version: 0.6.2 then the issue is gone... no bother then, thanks in advance.

zhongxinlei avatar May 03 '25 04:05 zhongxinlei