Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Targeting id's with scrapy css selector

Tags:

python

scrapy

HTML = '
    <div class="box">
        <div id="grid">
            <div class="content">hello</div>
        </div>
    </div>
'

--stuff happens here--

response.css('div.thread [*] div.mix').getall()

*how do I search for divs without a class? No matter what suggestion I find online I keep getting the error "expected something got delim..."

like image 386
runningmanjoe Avatar asked May 20 '26 17:05

runningmanjoe


1 Answers

You need to use # for an id attribute:

response.css('div#grid')

Or you can select it by attribute notation:

response.css('div[id="grid"]')
like image 62
gangabass Avatar answered May 22 '26 07:05

gangabass