Beispiel #1
0
async def on_message(message):
    if message.content.startswith('!insta'):
        names = message.content.split(' ')[1:]
        for name in names:
            try:
                bio = Instagram(name).bio
                cursor.execute(
                    '''INSERT INTO bios VALUES(
                                ?,
                                ?
               );''', (name, bio))
                connection.commit()
                await bot.send_message(
                    message.channel,
                    '%s was added to the monitoring ' % (name))

            except:
                await bot.send_message(
                    message.channel,
                    "Sorry I couldn't find a user by the name %s" % (name))

    elif message.content.startswith('!remove'):
        names = message.content.split(' ')[1:]
        for name in names:
            cursor.execute('''DELETE FROM bios WHERE name=?;''', (name, ))
            await bot.send_message(message.channel,
                                   '%s was removed successfully' % name)
Beispiel #2
0
def download_all(count_of_eshops=30, req=None):
    """
    A function for downloading it all-at-once.

    :param RequestHelper req: a Request helper class to be passed
    :param int count_of_eshops: Number of eshops to include.
    :return pandas.DataFrame: Data frame with all the data
    """

    # we run the Heureka first
    h = Heureka(req=req)
    h.run(count_of_eshops)

    # then we find the instagram links on the eshop's webpages
    e = EshopWebsite(req=req)
    e.run([shop['link'] for shop in h.output])

    # then use the information from web pages to collect instagram accounts
    i = Instagram(req=req)
    i.run([shop['instagram'] for shop in e.output if shop['instagram']])

    # here we create DataFrames
    df_h = pd.DataFrame(h.output).set_index('link')
    df_e = pd.DataFrame(e.output).set_index('url')
    df_i = pd.DataFrame(i.output).set_index('account')
    df_all = df_h.join(pd.merge(df_e, df_i, left_on='instagram', right_index=True))

    # and return the merged DataFrame
    return df_all
Beispiel #3
0
 def __init__(self, username):
     config = ConfigParser.ConfigParser()
     config.read('./config.properties')
     self.pinterest = Pinterest(username, config)
     self.googleplus = GooglePlus(username, config)
     self.youtube = YouTube(username, config)
     self.twitch = Twitch(username, config)
     self.vimeo = Vimeo(username, config)
     self.behance = Behance(username, config)
     self.instagram = Instagram(username, config)
     self.twitter = Twitter(username, config)
     self.github = Github(username, config)
     self.dict = dict()
Beispiel #4
0
def main():

    if len(sys.argv) < 2:
        fname = "Instagram_THORNAPPLE_2020-02-05~2020-02-05.json"
    else:
        fname = sys.argv[1]

    with open(fname, "r", encoding="utf-8") as f:
        data = json.loads(f.read())

    i = Instagram()
    analysed = i.analyse(data)

    pprint.pprint(analysed)
def index(url=None, error=None, media=None):

    if request.method == 'POST':
        try:
            data = Instagram(request.form["url"])
            media = data.get_download_url()
        except Exception as e:
            error = e

    return render_template("index.html",
                           method=request.method,
                           url=url,
                           error=error,
                           media=media)
    def __init__(self):
        self.bot = Instagram()

        self.window = tk.Tk()

        self.window.title("Instagram bot")
        self.window.geometry("900x100")
        #self.window.iconbitmap('instagram.png')
        self.window.resizable(0, 0)

        self.window.config(bg="#E6E6FA")

        self.create_widgets()

        self.window.mainloop()
Beispiel #7
0
    def __init__(self, username, password, thread_name, output_dir,
                 debug_mode=False):
        self.username = username
        self.password = password
        self.selected_thread_name = thread_name
        self.logged_in = False
        self.debug_mode = debug_mode
        self.media_folder = output_dir
        self.instagram = Instagram(username, password, debug_mode=debug_mode)
        self.selected_thread_id = ''

        if not os.path.exists(output_dir):
            os.mkdir(output_dir, 0755)

        self.dump_file = open(os.path.join(output_dir, 'dump_file.csv'), 'wb')
        self.csv_handler = csv.writer(self.dump_file, delimiter=',', quotechar='|')
Beispiel #8
0
def main():
    print('- -' * 14)
    print(f'|\tSession started {config.INSTAGRAM_USERNAME}\t |')
    print('- -' * 14, end='\n\n')

    ig = Instagram()

    # --------------------------------------

    print(f'\n∘ [{getTimeStamp()}] Getting timeline posts', end='\n\n')
    timeline = ig.getTimeline(count=200)
    for i, x in enumerate(timeline):
        if i % LIKE_STEP == 0:
            likePost(ig, x)
        if i % COMMENT_STEP == 0:
            commentPost(ig, x)
        if i % FOLLOW_STEP == 0:
            unfollowPoster(ig, x['shortcode'])

        randSleep()

    # --------------------------------------

    tagFeed = []
    for i in config.TAGS:
        print(f'∘ [{getTimeStamp()}] Getting posts for #{i}')
        tagFeed.extend(ig.searchTagFeed(i.replace('#', ''), count=200))
        randSleep()
    print()

    for i, x in enumerate(tagFeed):
        if i % LIKE_STEP == 0:
            likePost(ig, x)
        if i % COMMENT_STEP == 0:
            commentPost(ig, x)
        if i % FOLLOW_STEP == 0:
            followPoster(ig, x['shortcode'])

        randSleep()

    # --------------------------------------

    print('- -' * 14)
    print(f'|\t     Finished session!\t\t |')
    print('- -' * 14, end='\n\n')
Beispiel #9
0
    def post(self, *args, **kwargs):
        userSend = self.request.body.decode()
        msgobj = parse(userSend)
        if msgobj.MsgType == "text":
            if "instagram.com" in msgobj.Content:
                realurl = parseurl(msgobj.Content)
                insobj = Instagram(BASEPATH, realurl)
                imagePath = yield Executor.submit(insobj.fetchImage)
                res = yield Executor.submit(wexinClient.postImageMedia,
                                            imagePath)
                imgrepsone = IMAGE_TEMPLATE.format(
                    to_user=msgobj.FromUserName,
                    from_user=msgobj.ToUserName,
                    create_time=int(time.time()),
                    media_id=res.get("media_id"),
                )
                self.write(imgrepsone)
                return

        self.write("success")
Beispiel #10
0
def getImage(location, service='flickr'):

    returnJson = {}

    print(" 1. my token is " + request.get_cookie("insta_auth_token"))

    if service == 'flickr':
        ps = Flickr()
    elif service == 'insta':
        ps = Instagram()
    print("2. my token is " + request.get_cookie("insta_auth_token"))

    print("GETTING SHIT")
    ps.photo_lookup(location)
    print(" 3. my token is " + request.get_cookie("insta_auth_token"))
    photo = ps.get_next_photo()
    print(" 4. my token is " + request.get_cookie("insta_auth_token"))
    print(photo)

    return json.dumps(photo)
Beispiel #11
0
    def generate():
        for username in usernames:
            if username != "":

                # C:\..\static\asaf.gilboa
                userFolder = os.path.join(home_dir, "static", username)

                # Create directory for the user
                if not os.path.exists(userFolder):
                    os.makedirs(userFolder)
                else:
                    rmtree(userFolder)
                    os.makedirs(userFolder)

                insta = Instagram(username, userFolder)

                while insta.sum < insta.counter:
                    sleep(0.1)

                # Replace with Sagi's function
                list_of_bad = shtink_user(insta.pics_dic)
                user = User(insta.fullName, username, insta.profileUrl,
                            list_of_bad)

                if user.badLinks:
                    badUsers.append(user)  #User(url))
                elif insta.isPrivate:
                    privateUsers.append(user)
                else:
                    cleanUsers.append(user)
                yield "Scanned " + username + "'s profile...<br>"
        #x = 0
        #while x < 100:
        #print x
        #x = x + 10
        #time.sleep(0.2)
        #yield "data:" + str(x) + "\n\n"
        yield render_template('result.html',
                              privateUsers=privateUsers,
                              cleanUsers=cleanUsers,
                              badUsers=badUsers)
Beispiel #12
0
 def __init__(self, username, password):
     self.username = username
     self.password = password
     self.instagram = Instagram(username, password)
     self.logged_in = False
Beispiel #13
0
from selenium import webdriver
import random
from instagram import Instagram
from env import USERNAME, PASSWORD

try:
    instagram = Instagram()

    instagram.open()

    instagram.login(USERNAME, PASSWORD)

    while True:
        instagram.wait()
        instagram.follow_followers(USERNAME)
        instagram.wait()
        instagram.like_photos_with_tag_list(
            ["puppy", "pequines", "cachorro", "animal", "dog", "cute"])

        # q = input("Press:\n1) Follow Followers\n2) Like photos by Tag list\n0) Quit\n")

        # if q == "1":
        #    instagram.follow_followers(USERNAME)

        # elif q == "2":
        #    instagram.like_photos_with_tag_list(["puppy", "pequines", "cachorro", "animal", "dog", "cute"])

        # else:
        #    break
except Exception as e:
    print("Aconteceu um erro: ")
Beispiel #14
0
if __name__ == "__main__":
    driver = webdriver.Firefox(executable_path="geckodriver/geckodriver")
    driver.implicitly_wait(20)

    if not os.path.exists(config.DATABASE_PATH):
        print("Creating database ...")
        os.system("python3 database.py")

    conn = sqlite3.connect(config.DATABASE_PATH)
    cursor = conn.cursor()

    username, password = get_user_data()

    # Login
    utils = Utils(cursor)
    instagram = Instagram(username, password, driver)

    # Wait for login
    time.sleep(3)
    print("Login done")

    del password

    if new_account(instagram, utils):
        utils.insert_user(username)
        print("Getting accounts, please wait...")

        followers = instagram.get_followers(username)
        followees = instagram.get_followees(username)

        save_true_followers(instagram, utils, followers, followees)
Beispiel #15
0
'''
A simple code for finding your following's following list

'''


# TODO search something in full name field
def search_in_list(self, search_name, user_list):
    match_users = []
    for user in user_list:
        if fuzz.partial_ratio(search_name, user[1]) > 70:
            match_users.append(user)
    return match_users


ig = Instagram()
my_profile = ig.get_user_info_by_id(ig.my_id)
my_followers = ig.get_user_followers(ig.my_id,
                                     my_profile['user']['follower_count'])

users_for_search = my_followers[:]

# search in your follower list to find their followers
for user in my_followers:
    user_profile = ig.get_user_info_by_id(user[0])
    users_for_search += ig.get_user_followers(
        user[0], user_profile['user']['follower_count'])

with open('users_list', 'w') as fd:
    for user in users_for_search:
        fd.write(str(user))
Beispiel #16
0
from instagram import Instagram
from settings.settings import Settings

settings = Settings()
instagram = Instagram(settings.get_api_token())
result = instagram.scrape_profile('https://graph.instagram.com/me/media', [])
print(result)
from time import sleep
import string
import re
connection = sqlite3.connect('instagram')
cursor = connection.cursor()

cursor.execute('''CREATE TABLE IF NOT EXISTS bios(
                  name varchar(255),
                  bio text);''')

while True:
    cursor.execute('''SELECT * FROM bios''')
    results = cursor.fetchall()
    for user in results:
        try:
            bio = Instagram(user[0]).bio
        except:
            sleep(30)
        if bio != user[1]:
            webhook = DiscordWebhook(url='WEBHOOK URL')
            # create embed object for webhook
            print(user)
            embed = DiscordEmbed(title=user[0], description=bio, color=242424)

            # add embed object to webhook
            webhook.add_embed(embed)

            webhook.execute()

            cursor.execute('''UPDATE bios SET bio=? WHERE name=?''',
                           (bio, user[0]))
Beispiel #18
0
            )
        return 0


if __name__ == "__main__":
    limit_users = 200

    detector = Detector(
        join_path('models', 'shape_predictor_68_face_landmarks.dat'),
        join_path('models', 'dlib_face_recognition_resnet_model_v1.dat'),
        join_path('models', 'gender.pickle'),
    )
    graph = Graph(os.getenv('INSTAGRAM_NEO4J'))

    instagram = Instagram(
        os.getenv('INSTAGRAM_USERNAME'),
        os.getenv('INSTAGRAM_PASSWORD'),
    )
    current_user = os.getenv('INSTAGRAM_USERNAME')
    current_gender = 'unknown'

    log_event('info', 'trying to connect to Instagram ...')
    if not instagram.login():
        log_event('error', "couldn't connect to Instagram !")
        sys.exit(1)

    log_event('info', 'fetching logged-in user followers ...')
    followers = instagram.followers(instagram.username_id)
    if followers['status'] != 'ok':
        log_event('error', 'invalid Instagram status ' + followers['status'])
        sys.exit(2)
Beispiel #19
0
def authenticate_instagram_callback():
    Instagram().auth()
Beispiel #20
0
        n = len(posts)
        currposts = posts
        while n < max_posts and currposts != []:
            currposts = scraper.get_posts(user['username'], user['id'])
            posts = posts + currposts
            n = len(posts)

        scraper.logout()

        return 0
    else:
        return 1


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Instagram posts and user scraper.')
    parser.add_argument('--N', type=int, default=100, help='Number of posts to scrape')
    parser.add_argument('--u', type=str, default='mattia.gasparini.5', help='Target username')
    parser.add_argument('--t', type=str, help='Target hashtag to scrape posts')

    args = parser.parse_args()

    # ig account credentials (needed for posts, not for users data)
    ig_credentials = json.load(open('credentials.json', 'r'))
    scraper = Instagram(ig_credentials)

    if not args.t:
        get_user_posts(scraper, args.u, args.N)
    else:
        get_hashtag_posts(scraper, args.t, args.N)
            print "Failed to fetch '{}' followers".format(follower["username"])
            continue
        elif targets["status"] != 'ok':
            print "Invalid status for '{}' followers: {}".format(
                follower["username"], targets["status"])
            continue
        else:
            users.extend(targets["users"])

        parallel_downloader(users)
        time.sleep(1)


if __name__ == "__main__":
    instagram = Instagram(
        username=os.getenv('INSTAGRAM_USERNAME', ''),
        password=os.getenv('INSTAGRAM_PASSWORD', ''),
    )
    if not instagram.login():
        print "Couldn't sign-in into Instagram."
        sys.exit(1)

    if not os.path.exists('images'):
        os.mkdir('images')

    try:
        application(instagram)
    except BaseException as e:
        print "Exception on {}".format(e)

    instagram.logout()
Beispiel #22
0
    new_im = Image.new('RGB', (size, size), fill_color)
    new_im.paste(im, (int((size - x) / 2), int((size - y) / 2)))
    img_path = img_path[:-3] + "jpg"
    new_im.save(img_path)


rc = praw.Reddit(client_id="362R_F8jZdyhiw",
                 client_secret=clientscrt,
                 user_agent="unexpected bot")

subreddit = rc.subreddit("memes")
caption_bottom = "\n\n\n\n\n\n #meme #memes #funny #dankmemes #memesdaily #funnymemes #lol #dank #humor #follow #like #dankmeme #lmao #love #anime #ol #edgymemes #dailymemes #comedy #instagram #fun #offensivememes #fortnite #funnymeme #tiktok #memer #memez #memepage #memestagram #bhfyp"
base = "/home/"
uploaded_number = 0

instagram_client = Instagram(user, passwrd)

while 1:
    if 1:
        cont = 0
        for sub in subreddit.top('day'):
            if cont >= 1: break

            id = sub.url.split("/")[-1]
            url = sub.url
            path = os.path.join(base, f"{id}")
            id = id[:-3] + "jpg"

            if not sub.stickied and not_uploaded(id):

                req = requests.get(url)
Beispiel #23
0
from instagram import Instagram
import time

instagram_url = "https://www.instagram.com/"

instagram = Instagram(instagram_url)
time.sleep(2)

phone_xpath = '//*[@id="loginForm"]/div/div[1]/div/label/input'
psw_xpath = '//*[@id="loginForm"]/div/div[2]/div/label/input'
btn_xpath = '//*[@id="loginForm"]/div/div[3]/button/div'

instagram.connection(phone_xpath, psw_xpath, btn_xpath)

time.sleep(2)

search_xpath = '//*[@id="react-root"]/section/nav/div[2]/div/div/div[2]/input'
time.sleep(2)
b_xpath = '//*[@id="react-root"]/section/nav/div[2]/div/div/div[2]/div[3]/div/div[2]/div/div/a'
time.sleep(2)
instagram.search_user(search_xpath, b_xpath)
time.sleep(2)

suscriber_xpath = '//*[@id="react-root"]/section/main/div/header/section/ul/li[2]/a'
suscriber_btn_class = "sqdOP  L3NKy   y3zKF     "

instagram.follow_users(suscriber_xpath)
# while True:
#     instagram.follow_users(suscriber_xpath)
Beispiel #24
0
        elif 'restart' in query:
            check = input("Want to restart your computer ? (y/n): ")
            if check == 'n':
                exit()
            else:
                os.system("shutdown /r /t 1")
        elif 'system' in query:
            speak("This are the features of your device\n")
            speak(platform.platform())
            speak(platform.system())
            speak(platform.processor())
            speak(platform.architecture())

        elif 'check instagram' in query:
            speak("Opening instagram dp downloader")
            Instagram()
        elif 'bored' in query or 'game' in query:
            speak("Feeling bored sir, let's play a game")
            os.system('python alien-invasion/game.py')

        else:
            speak("Do you want me to search " + query)
            answer = take_command()
            if "yes" in answer or "yup" in answer or "thrill me" in answer:

                speak('Searching...')
                try:
                    try:
                        res = client.query(query)
                        results = next(res.results).text
                        speak('WOLFRAM-ALPHA says - ')
Beispiel #25
0
@perms.owner()
async def lock(ctx: commands.Context, *reason: str):
    # TODO stick this into the db
    global lockdown_mode

    lockdown_mode = not lockdown_mode
    for server in db['server']:
        await bot.get_channel(
            server.get('archive_channel')
        ).send('Lockdown mode ' +
               ('deactivated\n' if not lockdown_mode else 'activated.\n') +
               (('Reason:' + ' '.join(reason)) if len(reason) else ''))


@bot.command(brief='Restarts the bot.')
@perms.owner()
async def restart(ctx: commands.Context):
    await ctx.send('Restarting...')

    try:
        await bot.close()
    except:
        pass
    finally:
        os.system('python main.py')


bot.add_cog(Reddit(bot, db))
bot.add_cog(Instagram(bot, db))
bot.run(db['settings'].find_one(name='token')['value'])
from instagram import Instagram
from selenium import webdriver
from time import sleep
from comment_list import COMMENT_LIST

URL = "https://www.instagram.com/p/CCZfJc9jbFz/"
USERNAME = "******"
PASSWORD = "******"
COMMENT_NUMBER = 1000

COMMENT_LIST = COMMENT_LIST

USER_NUMBER_PER_COMMENT = 2

DRIVER = webdriver.Chrome()

INSTAGRAM = Instagram(DRIVER, URL)
INSTAGRAM.navigate()
INSTAGRAM.login(USERNAME, PASSWORD)
INSTAGRAM.comment(COMMENT_LIST, USER_NUMBER_PER_COMMENT, COMMENT_NUMBER)

Beispiel #27
0
import pickle
from instagram import Instagram

#####################################
#####################################
#####################################
#enter your new password here and run the program
updatepass = "******"

#####################################
#####################################
#####################################

usrname = '_akash__06_'  #constant
pwd = None
currpwd = pickle.load(open("PasswordFile.p", "rb"))

myID = Instagram(usrname, currpwd)
#myID.logIn()
#myID.changePassword(updatepass)
print(myID.Password())
myID.close()
Beispiel #28
0
def main():
    insta = Instagram(USERNAME, PASSWORD)
    insta.log_in(is_facebook=True, is_two_factor=True)
    insta.enter_profile(user_name='forbes')
    insta.enter_profile(self_profile=True)
Beispiel #29
0
            for chunk in r.iter_content(1000):
                f.write(chunk)
        print(f"{file_name} downloaded succesfully!")
    else:
        print(f"{file_name} already exists")


url = args.url
tags = args.tag
detail = args.detail
photos = args.photos
videos = args.videos
username = args.username

if username:
    account = Instagram(account=username)
    if detail:
        data, file_name = account.save_details()
        dump_json(data, file_name)

    if photos:
        print(f"Getting {username} photos!!")
        for contents in account.contents.get_all_contents():
            for content in contents:
                if content['type'] == 'photo':
                    if detail:
                        dump_json(content, content['id'])
                    download(content['download_url'], username,
                             content['file_name'])

    elif videos: