Snippets

Andrew Image grab

Created by Andrew
''' So the image grabs arnt working 100% ''' 
# how come I can grab the src but not data-src of the same image tag.
# code
                    try:
                        imageurldatasrc = item.find('img',  {'class': {'s-item__image'}})['data-src']
                        print('Image: ', imageurldatasrc)
                    except Exception as e:
                        print('imageurldatasrc Exception: ', e)

                    try:
                        imageurlsrc = item.find('img',  {'class': {'s-item__image-img'}})['src']
                        print('imageurlsrc: ', imageurlsrc)
                    except Exception as e:
                        print('imageurlsrc Exception: ', e)
                        continue

# output
imagediv:  <div class="s-item__image"><a _sp="p2351460.m1686.l7400" aria-hidden="true" data-track='{"eventFamily":"LST","eventAction":"ACTN","actionKind":"NAVSRC","actionKinds":["NAVSRC"],"operationId":"2351460","flushImmediately":false,"eventProperty":{"moduledtl":"mi:1686|iid:47|li:7400|luid:1|scen:Listings","parentrq":"6df39c6016c0ad4c1f6b566aff07917f","pageci":"0f98f172-b959-11e9-a199-74dbd1806721"}}' href="https://www.ebay.com/itm/Asics-Dynaflyte-2-Womens-T7D5N-9020-Black-Pink-Persian-Running-Shoes-Size-6-5/372495140123?epid=11022991501&amp;hash=item56ba70c51b:g:6nQAAOSw~X1bfsru" tabindex="-1"><div class="s-item__image-wrapper"><div class="s-item__image-helper"></div><img alt="Asics Dynaflyte 2 Womens T7D5N-9020 Black Pink Persian Running Shoes Size 6.5" class="s-item__image-img" data-src="https://i.ebayimg.com/thumbs/images/g/6nQAAOSw~X1bfsru/s-l225.jpg" src="https://ir.ebaystatic.com/cr/v/c1/s_1x2.gif"/></div></a></div>
imageurldatasrc Exception:  'NoneType' object is not subscriptable
imageurlsrc:  https://ir.ebaystatic.com/cr/v/c1/s_1x2.gif

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.