├── .gitignore
├── LICENSE
├── Procfile
├── README.md
├── app.json
├── app.py
├── instagram.py
├── requirements.txt
├── runtime.txt
└── templates
├── display.html
├── downloadpost.html
├── index.html
└── post.html
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 | MANIFEST
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 | .pytest_cache/
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 | local_settings.py
57 | db.sqlite3
58 |
59 | # Flask stuff:
60 | instance/
61 | .webassets-cache
62 |
63 | # Scrapy stuff:
64 | .scrapy
65 |
66 | # Sphinx documentation
67 | docs/_build/
68 |
69 | # PyBuilder
70 | target/
71 |
72 | # Jupyter Notebook
73 | .ipynb_checkpoints
74 |
75 | # pyenv
76 | .python-version
77 |
78 | # celery beat schedule file
79 | celerybeat-schedule
80 |
81 | # SageMath parsed files
82 | *.sage.py
83 |
84 | # Environments
85 | .env
86 | .venv
87 | env/
88 | venv/
89 | ENV/
90 | env.bak/
91 | venv.bak/
92 |
93 | # Spyder project settings
94 | .spyderproject
95 | .spyproject
96 |
97 | # Rope project settings
98 | .ropeproject
99 |
100 | # mkdocs documentation
101 | /site
102 |
103 | # mypy
104 | .mypy_cache/
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Sumanjay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: gunicorn app:app --log-file=-
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # InstaFlask
2 | ### Python-ica-Flask way to view Instagram Profile, Download HD DP/Photo/Video of users from link.
3 | ### Try it [here](https://instaflask.pythonanywhere.com/)
4 | ## Screenshots:
5 |
6 | ### Homepage:
7 |
8 |
9 | ### Details page:
10 |
11 |
12 | --------------------
13 | You can also deploy it to Heroku in case you want your own version of InstaFlask!
14 |
15 | Just fork and click on "Deploy to Heroku Button"
16 |
17 | [](https://heroku.com/deploy?template=https://github.com/cyberboysumanjay/instaflask/tree/master)
18 |
19 |
20 | © [Sumanjay](https://cyberboysumanjay.github.io)
21 | All Rights Reserved
22 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "InstaFlask",
3 | "description": "Python-ica-Flask way to view Instagram Profile, Download HD DP/Photo/Video of users from link.",
4 | "keywords": [
5 | "flask",
6 | "python",
7 | "instagram"
8 | "downloader"
9 | ],
10 | "repository": "https://github.com/cyberboysumanjay/InstaFlask"
11 | }
12 |
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template,request
2 | import instagram
3 |
4 | app = Flask(__name__)
5 | app.secret_key = 'iknowyoucanseethis'
6 |
7 | @app.route('/')
8 | @app.route('/home')
9 | @app.route('/index')
10 | def home():
11 | return render_template("index.html")
12 |
13 | @app.route('/details', methods=['GET', 'POST'])
14 | def details():
15 | if request.method == 'POST':
16 | result = request.form
17 | username=(result['userid'])
18 | '''
19 | id=''
20 | try:
21 | id=instagram.getID(username)
22 | if id=='invalid_username':
23 | return '
Invalid Username
Please go back and enter a valid username to continue'
24 | except Exception as e:
25 | print(e)
26 | try:
27 | user_data=instagram.userDetails(id)
28 | except Exception as e:
29 | print(e)
30 | '''
31 | profile = instagram.userDetails(username)
32 | if profile is None:
33 | return 'Invalid Username
Please go back and enter a valid username to continue'
34 |
35 | dp_url = profile.profile_pic_url
36 | hd_dp_url = profile.profile_pic_url #No Access to HD Photos without Login (F**k You Instagram!)
37 | username = profile.username
38 | fullname = profile.full_name
39 | private_profile = profile.is_private
40 | is_verified = profile.is_verified
41 | total_posts = profile.mediacount
42 | followers = profile.followers
43 | following = profile.followees
44 | bio = profile.biography
45 | if bio is None:
46 | bio ='None'
47 | external_url = profile.external_url
48 | if external_url is None:
49 | external_url='None'
50 | return render_template("display.html",dp_url=dp_url,username=username,fullname=fullname,private_profile=private_profile,is_verified=is_verified,total_posts=total_posts,followers=followers,following=following,bio=bio,external_url=external_url,hd_dp_url=hd_dp_url)
51 |
52 | @app.route('/post', methods=['GET', 'POST'])
53 | def post():
54 | try:
55 | if request.method == 'GET':
56 | return render_template("downloadpost.html")
57 | else:
58 | result = request.form
59 | post_link = (result['postlink'])
60 | full_name,followers,followees,is_verified,is_private,bio,external_url, owner_username, url, caption, caption_hashtags, caption_mentions, is_video, media_url, likes, comments = instagram.get_media_details(post_link)
61 | return render_template('post.html',full_name=full_name,followers=followers,followees=followees,is_verified=is_verified,is_private=is_private,bio=bio,external_url=external_url,owner_username=owner_username,url=url,caption=caption,caption_hashtags=caption_hashtags,caption_mentions=caption_mentions,is_video=is_video,comments=comments,likes=likes,media_url=media_url)
62 | except :
63 | return "Something went wrong. Is your URL Correct? Make sure the link isn't Private."
64 |
65 | if __name__ == '__main__':
66 | app.debug = True
67 | app.run(host='0.0.0.0',port=5000,use_reloader=True)
68 |
--------------------------------------------------------------------------------
/instagram.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import re
3 | import requests
4 | from instaloader import Instaloader, Post, Profile
5 |
6 | L=Instaloader()
7 |
8 | def userDetails(username):
9 | try:
10 | profile = Profile.from_username(L.context, username)
11 | return profile
12 | except Exception:
13 | return None
14 |
15 | def get_media_details(link):
16 | link = link.split("?")[0]
17 | shortcode = link.split('/p/')[1].replace('/', '')
18 | post=Post.from_shortcode(L.context,shortcode)
19 | owner_profile=post.owner_profile
20 | full_name=owner_profile.full_name
21 | followers=owner_profile.followers
22 | followees=owner_profile.followees
23 | is_verified=owner_profile.is_verified
24 | is_private=owner_profile.is_private
25 | bio=owner_profile.biography
26 | external_url=owner_profile.external_url
27 | owner_username=post.owner_username
28 | url=post.url
29 | caption=post.caption
30 | caption_hashtags=post.caption_hashtags
31 | if len(caption_hashtags)==0:
32 | caption_hashtags=None
33 | caption_mentions=post.caption_mentions
34 | if len(caption_mentions)==0:
35 | caption_mentions=None
36 | is_video=post.is_video
37 | video_url=post.video_url
38 | if(is_video):
39 | media_url=video_url
40 | else:
41 | media_url=url
42 | likes=post.likes
43 | comments=post.comments
44 | return(full_name,
45 | followers,
46 | followees,
47 | is_verified,
48 | is_private,
49 | bio,
50 | external_url,
51 | owner_username,
52 | url,
53 | caption,
54 | caption_hashtags,
55 | caption_mentions,
56 | is_video,
57 | media_url,
58 | likes,
59 | comments)
60 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask
2 | gunicorn
3 | httplib2
4 | requests
5 | instaloader
6 |
--------------------------------------------------------------------------------
/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.6.8
2 |
--------------------------------------------------------------------------------
/templates/display.html:
--------------------------------------------------------------------------------
1 | {% extends "index.html" %} {% block content %}
2 |
3 | Details fetched! Now you can stalk the user....
4 |
7 |
8 |
9 |
10 |

11 |
12 |
13 |
14 |
Here are the details of {{ fullname }}!
15 |
16 |
This profile seriously looks interesting.
17 |
18 |
19 |
20 | Username: {{ username }}
Fullname: {{ fullname }}
Biography: {{ bio }}
Private Profile: {{ private_profile }}
Verified Profile: {{ is_verified }}
Total Posts: {{ total_posts }}
Followers: {{ followers
21 | }}
Following: {{ following }}
External URL: {{ external_url }}
22 |
23 |
24 |
28 |
29 | {% endblock %}
--------------------------------------------------------------------------------
/templates/downloadpost.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | InstaFlask
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
17 |
18 |
23 |
24 |
25 |
26 |
27 | {% block content %}
28 |
29 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
44 |
Follow me
45 |
46 |
47 |
48 | {% endblock %}
49 |
50 |
51 |
52 |
53 |
54 |
55 |
Visitors
56 |

57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | InstaFlask
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
17 |
18 |
23 |
24 |
25 |
26 |
27 | {% block content %}
28 |
29 |
38 |
39 |
42 |
43 |
44 |
45 |
49 |
50 |
51 |
Post Downloader
52 |
53 |
54 | {% endblock %}
55 |
56 |
57 |
58 |
59 |
60 |
Visitors Count
61 |

64 |
65 |
66 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/templates/post.html:
--------------------------------------------------------------------------------
1 | {% extends "index.html" %} {% block content %}
2 |
3 |
4 | Media Fetched!
5 |
8 |
9 |
10 |
11 |

12 |
13 |
14 |
15 | Fullname: {{ full_name }}
16 | Username: {{ owner_username }}
17 | Followers Count: {{ followers }}
18 | Following Count: {{ followees }}
19 | Private Account: {{ is_private }}
20 | Verified Account: {{ is_verified }}
21 | Bio: {{ bio }}
22 | External URL: {{ external_url }}
23 | Video: {{ is_video }}
24 | Caption: {{ caption }}
25 | Hashtags: {{ caption_hashtags }}
26 | Mentions: {{ caption_mentions }}
27 | Likes Count: {{ likes }}
28 | Comments Count: {{ comments }}
29 |
30 |
31 |
32 |
Download Media [HD]
33 |
Download another Media
34 |
35 |
36 |
37 | {% endblock %}
38 |
--------------------------------------------------------------------------------