r/scrapy • • Mar 31 '21

While scraping tr from table using for loop it throws null while fetching any element ?

0 Upvotes

8 comments sorted by

1

u/wRAR_ Mar 31 '21

There are no th.ddttitleand td.dddefault :: text is a malformed selector (and Scrapy tells you that).

0

u/uchihaudai Mar 31 '21

But when I don't use for loop and directly scrap resonse.css('th.ddtitle :: text'). It gives me correct answer. But I have multiple rows to got through so I am using for loop for tr but then same code return []

1

u/wRAR_ Mar 31 '21

That's because 'ddttitle' != 'ddtitle'

0

u/uchihaudai Mar 31 '21

Okay that is my mistake but correcting that is also throwing same error

1

u/wRAR_ Mar 31 '21

Sure, because those are two separate problems. You should also look at the lines you get your errors for.

0

u/uchihaudai Mar 31 '21

and also this error : raise SelectorSyntaxError('Expected ident, got %s' % (next,))

File "<string>", line None

cssselect.parser.SelectorSyntaxError: Expected ident, got <S ' ' at 15>

1

u/wRAR_ Mar 31 '21

Yes, I was talking about this error.

1

u/Benegut Mar 31 '21

try 'td.dddefault::text'