Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ You can find detailed commands usage [here](doc/COMMANDS.md).

5. Run `pip install -r requirements.txt`

6. Open the `credentials.ini` file in the `config` folder and write your Instagram account username and password in the corresponding fields
6. Open the `credentials.ini` file in the `config` folder and write your Instagram account username and password in the corresponding fields. Or use `hikerapi_token` from https://hikerapi.com/tokens (first 100 requests are free after registration and confirmation of your tg)

Alternatively, you can run the `make setup` command to populate this file for you.

7. Run the main.py script in one of two ways
7. Run the main.py script in one of three ways

* As an interactive prompt `python3 main.py <target username>`
* Or execute your command straight away `python3 main.py <target username> --command <command>`
* Or execute using HikerAPI token via env `HIKERAPI_TOKEN=<hikerapi token> python3 main.py <target username> -c <command>`

### Use Osintgram v2 (beta)
You can use Osintgram2 beta just switching to `v2` [branch](https://github.com/Datalux/Osintgram/tree/v2).
Expand Down
3 changes: 2 additions & 1 deletion config/credentials.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[Credentials]
username =
password =
password =
hikerapi_token =
4 changes: 2 additions & 2 deletions docker_reqs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requests==2.24.0
requests-toolbelt==0.9.1
geopy>=2.0.0
prettytable==0.7.2
instagram-private-api==1.6.0
gnureadline>=8.0.0
gnureadline>=8.0.0
hikerapi==1.7.1
24 changes: 16 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python3

from src.Osintgram import Osintgram
import argparse
from src import printcolors as pc
from src import artwork
import os
import sys
import signal
import argparse

from src import artwork, config
from src import printcolors as pc
from src.hikercli import HikerCLI, hk
from src.Osintgram import Osintgram

is_windows = False

Expand All @@ -18,7 +20,10 @@

def printlogo():
pc.printout(artwork.ascii_art, pc.YELLOW)
pc.printout("\nVersion 1.1 - Developed by Giuseppe Criscione\n\n", pc.YELLOW)
pc.printout("\nVersion 1.1 - Developed by Giuseppe Criscione", pc.YELLOW)
pc.printout(
f"\nHikerAPI {hk.__version__} https://hikerapi.com/help/about\n\n", pc.YELLOW
)
pc.printout("Type 'list' to show all allowed commands\n")
pc.printout("Type 'FILE=y' to save results to files like '<target username>_<command>.txt (default is disabled)'\n")
pc.printout("Type 'FILE=n' to disable saving to files'\n")
Expand Down Expand Up @@ -92,6 +97,7 @@ def completer(text, state):
else:
return None


def _quit():
pc.printout("Goodbye!\n", pc.RED)
sys.exit(0)
Expand All @@ -118,8 +124,10 @@ def _quit():
args = parser.parse_args()


api = Osintgram(args.id, args.file, args.json, args.command, args.output, args.cookies)

if config.getHikerToken():
api = HikerCLI(args.id, args.file, args.json, args.command, args.output, args.cookies)
else:
api = Osintgram(args.id, args.file, args.json, args.command, args.output, args.cookies)


commands = {
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
requests==2.24.0
requests-toolbelt==0.9.1
geopy>=2.0.0
prettytable==0.7.2
instagram-private-api==1.6.0
gnureadline>=8.0.0; platform_system != "Windows"
pyreadline==2.1; platform_system == "Windows"
pyreadline==2.1; platform_system == "Windows"
hikerapi==1.7.1
27 changes: 17 additions & 10 deletions src/Osintgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import codecs
from pathlib import Path

import requests
import httpx
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

Expand Down Expand Up @@ -598,27 +598,34 @@ def get_total_likes(self):

data = self.__get_feed__()

for post in data:
like_counter += post['like_count']
posts += 1
likes = [int(p["like_count"]) for p in data]
posts = len(likes)
like_counter = sum(likes)
min_ = min(likes)
max_ = max(likes)
avg = int(like_counter / posts)
result = f" likes in {posts} posts (min: {min_}, max: {max_}, avg: {avg})\n"

if self.writeFile:
file_name = self.output_dir + "/" + self.target + "_likes.txt"
file = open(file_name, "w")
file.write(str(like_counter) + " likes in " + str(like_counter) + " posts\n")
file.write(str(like_counter) + result)
file.close()

if self.jsonDump:
json_data = {
'like_counter': like_counter,
'posts': like_counter
"like_counter": like_counter,
"posts": posts,
"min": min_,
"max": max_,
"avg": avg,
}
json_file_name = self.output_dir + "/" + self.target + "_likes.json"
with open(json_file_name, 'w') as f:
with open(json_file_name, "w") as f:
json.dump(json_data, f)

pc.printout(str(like_counter), pc.MAGENTA)
pc.printout(" likes in " + str(posts) + " posts\n")
pc.printout(result)

def get_media_type(self):
if self.check_private_profile():
Expand Down Expand Up @@ -798,7 +805,7 @@ def get_photo_description(self):
if self.check_private_profile():
return

content = requests.get("https://www.instagram.com/" + str(self.target) + "/?__a=1")
content = httpx.get("https://www.instagram.com/" + str(self.target) + "/?__a=1")
data = content.json()

dd = data['graphql']['user']['edge_owner_to_timeline_media']['edges']
Expand Down
5 changes: 5 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import configparser
import sys

Expand Down Expand Up @@ -40,3 +41,7 @@ def getPassword():
except KeyError:
pc.printout('Error: missing "password" field in "config/credentials.ini"\n', pc.RED)
sys.exit(0)


def getHikerToken():
return config["Credentials"].get("hikerapi_token") or os.getenv("HIKERAPI_TOKEN")
Loading
Loading