I am trying to extract text from all td of a table from the below page. I am using CSS selector for this but somehow it not giving any output. I double-checked my CSS selector script in the browser inspect it works there but not in Scrapy.
HTML LInk: https://trusting-sinoussi-0dbf65.netlify.app/
In this HTML page I got two tables with same name, first one has nothing in it and second one has all data. And this is my scrapy code for selecting the tr and then extracting td's text. There is more than one table so I used the summary attribute to select the table. I am using for loop to extract td's from all the tr. So, in variable courses, I scraped till all tr and then passed that to for loop to extract td from each tr. but somehow output only shows for first tr only it is not selecting all the tr from this table
When I extract using
response.css('tr').extract()
OUTPUT includes only first two tr
But I want all td's text inside each tr so I tried to use td instead of tr
response.css('td.dddefault ::text').extract()
then it returns all the td from the table. **But I am not able to understand that when using tr as ectracting tag it only outputs first 2 rows values??? why? **
def course_scrap(self, response):
print('course slected')
courses = response.css('table.datadisplaytable[summary="This layout table is used to present the course found"] tr')
for course in courses:
trs = course.css('td.dddefault ::text').extract()
print(trs)
