I need to count the number of images (in this case 1 image). Apparently using "len()"?
Here is HTML:
<div class="detail-headline">
Fotogaléria
</div>
<div class="detail-indent">
<table id="ctl00_ctl00_ctl00_containerHolder_mainContentHolder_innnerContentHolder_ZakazkaControl_ZakazkaObrazky1_ObrazkyDataList" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;">
<tr>
<td align="center" style="width:25%;">
<div id="ctl00_ctl00_ctl00_containerHolder_mainContentHolder_innnerContentHolder_ZakazkaControl_ZakazkaObrazky1_ObrazkyDataList_ctl02_PictureContainer">
<a title="1-izb. Kaspická" class="highslide detail-img-link" onclick="return hs.expand(this);" href="/imgcache/cache231/3186-000393~8621457~640x480.jpg"><img src="/imgcache/cache231/3186-000393~8621457~120x120.jpg" class="detail-img" width="89" height="120" alt="1-izb. Kaspická" /></a>
</div>
</td><td></td>
</tr>
</table>
</div>
I used before HTMLParser and the number of images must be added to "self.srcData".. Previous code:
def handle_starttag(self, tag, attrs):
if tag == 'div' and len(attrs) > 1 and attrs[1][0] == 'class' and attrs[1][1] == 'detail-headline' \
and self.srcData[self.getpos()[0]].strip() == u'Realitná kancelária':
self.status = 2
if self.status == 2 and tag == 'div' and len(attrs) > 0 and attrs[0][0] == 'class' and attrs[0][1] == 'name':
self.record[-1] = decode(self.srcData[self.getpos()[0]].strip())
self.status = 0
Then (check start tag).. Like this?
if tag == 'div' and len(attrs) > 0 and attrs[0][0] == 'class' and attrs[0][1] == 'detail-headline' \
and self.srcData[self.getpos()[0]].strip() == 'Fotogaléria':
self.status = 3
Is it ok? And...? Thanks.