Projects STRLCPY snscrape Commits 2ce014ad
🤬
  • fixed edge case for videos that have data-link-attr but no href attribute

  • Loading...
  • Tristan Lee committed 2 years ago
    2ce014ad
    1 parent d32c9add
  • ■ ■ ■ ■ ■
    snscrape/modules/vkontakte.py
    skipped 176 lines
    177 177   continue
    178 178   if 'data-video' in a.attrs:
    179 179   # Video
     180 + if 'data-link-attr' in a.attrs:
     181 + hrefUrl = urllib.parse.unquote(a.attrs['data-link-attr'].split('to=')[1].split('&')[0])
     182 + else:
     183 + hrefUrl = f'https://vk.com{a["href"]}'
    180 184   video = Video(
    181 185   id = a['data-video'],
    182 186   list = a['data-list'],
    183 187   duration = int(a['data-duration']),
    184  - url = f'https://vk.com{a["href"]}',
     188 + url = hrefUrl,
    185 189   thumbUrl = a['style'][(begin := a['style'].find('background-image: url(') + 22) : a['style'].find(')', begin)],
    186 190   )
    187 191   continue
    skipped 202 lines
Please wait...
Page is in error, reload to recover