ehThind
ehThind

Reputation: 31

Issue creating the correct CSS Selector

I have been at this for a while and am throwing in the towel for help. I am trying to scrap this page specifically I am trying to get access to every table row that has information in it as highlighted green in the following picture. I do no need the table headers, just the rows.

enter image description here

With Scrapy I am able to get to each section area (where it says "Main Campus") with the following selector

response.css('.datadisplaytable .datadisplaytable')

I use .datadisplaytable twice because the tables I am trying to select are inside a table with that class. After that what seems logical to me to get to the table row I am after would be to use the following selector

response.css('.datadisplaytable .datadisplaytable tbody:nth-child(2)')

However, I get nothing with this selector. What am I doing wrong?

Upvotes: 0

Views: 44

Answers (1)

Sunny Patel
Sunny Patel

Reputation: 8078

Your selector is a bit off. You're not trying to get the 2nd <tbody/> tag.

.datadisplaytable .datadisplaytable tbody tr:nth-child(n+2)

That will get you all the rows, and skip the header for each table.

Upvotes: 1

Related Questions