Add Script Download IG Post Using Python&Instaloader module
This commit is contained in:
parent
5c4acb7d41
commit
c95b53ecb0
33
python_ig_downloader.py
Normal file
33
python_ig_downloader.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#Python
|
||||||
|
import instaloader
|
||||||
|
import re
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
def download_image(post_url):
|
||||||
|
# Get the post from the URL
|
||||||
|
url_id = re.search(r'https://www.instagram.com/(reel|p)/(.*)/',post_url)
|
||||||
|
url_id_post = url_id.group(2)
|
||||||
|
datenow = datetime.datetime.now().strftime('%d-%m-%Y-%H-%M-%S')
|
||||||
|
# Create an Instaloader instance
|
||||||
|
Name= (f'{datenow}_{url_id_post}')
|
||||||
|
#Name= url_id_post
|
||||||
|
L = instaloader.Instaloader(filename_pattern=Name)
|
||||||
|
|
||||||
|
#get Post
|
||||||
|
post = instaloader.Post.from_shortcode(L.context, url_id_post)
|
||||||
|
|
||||||
|
|
||||||
|
# Download the post
|
||||||
|
L.download_post(post, target=post.owner_username)
|
||||||
|
print(f'File saved in folder {post.owner_username}/ dengan nama file {Name}')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Get the post URL
|
||||||
|
# post_url = 'https://www.instagram.com/p/Cua9Aw-BZRz/?igshid=MzRlODBiNWFlZA=='
|
||||||
|
post_url = 'https://www.instagram.com/reel/CsVi19-gHVY/?igshid=MzRlODBiNWFlZA=='
|
||||||
|
# post_url = 'https://www.instagram.com/p/CueKypRP6pf/?igshid=MzRlODBiNWFlZA=='
|
||||||
|
# post_url = 'https://www.instagram.com/p/Cuohb_qpnBY/?igshid=MzRlODBiNWFlZA=='
|
||||||
|
# match = re.search(r'https://www.instagram.com/(reel|p)/(.*)/', post_url[1])
|
||||||
|
# print(match.group(2))
|
||||||
|
# Download the image
|
||||||
|
download_image(post_url)
|
Loading…
Reference in New Issue
Block a user