У меня есть фрейм данных комментариев Instagram, как показано ниже.
Identifier Comments
0 17870137606657366 Why the old Pike/Lyrik?
1 17912124778416809 This is good
2 18135501799061646 So clean
3 18046324513240472 Looks like a Decoy
Обратите внимание, что «Идентификатор» не является идентификатором носителя.
Я попытался преобразовать df ['Identifier' ] в URL-адрес, как показано ниже, но этот метод работает только для Instagram Media ID.
def getInstagramUrlFromMediaId(media_id):
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
shortened_id = ''
while media_id > 0:
remainder = media_id % 64
# dual conversion sign gets the right ID for new posts
media_id = (media_id - remainder) // 64;
# remainder should be casted as an integer to avoid a type error.
shortened_id = alphabet[int(remainder)] + shortened_id
return 'https://instagram.com/p/' + shortened_id + '/'