DEV Community

Steffan Jensen
Steffan Jensen

Posted on • Updated on

How I made a Instagram Bot with face detection.

Instagram scraper with autopost and face detection.

I made an Instagram Bot which autoscraped peoples profiles took a machine learning module and reposted the images back to Instagram. I am new to python, so many of the fundamentals are missing, all feedback are good.

This was maybe my third python bot, I had played little around with different social network bots on Github, they all ended up on the same road, liking pictures of dogs, commercials and other weird stuff, I reached out to the bot creators most said it was impossible, too much work.

Download My Instagram Bot:
https://github.com/instagrambot/Instagram-scraper-with-autopost

How I implemented face detection

So i ended up implementing it myself with only 2 lines of code.

    image = face_recognition.load_image_file(instapath)
    face_locations = face_recognition.face_locations(image)
    # If no face located scrape the next profile
    if not face_locations:
        print("There is no Face Detected scraping next profile")
        x += 1
        instascraper()
    else:
        print("There is a Face Detected scraping and posting this image")

Face detection at work on a live webcam

Instagram Scraper

I had already made the scraper/reposter myself within a few days, so to implement this code and it just worked.. was perfect

My script right now have a few third party packages and it's really fun to see how easy it's it to implement different modules. I think Python is a really fun language and the possibilities and endless.

My Instagram Scraper Website:
https://instabotai.com

Download My Instagram Bot:
https://github.com/instagrambot/Instagram-scraper-with-autopost

Oldest comments (3)

Collapse
 
kave_me profile image
Kave Mohammadi

thats a nice composition, btw, what is the USE of face detection in your bot?

Collapse
 
reliefs profile image
Steffan Jensen • Edited

Scrape the image of username if face is detected in image repost else scrape the image of next username.

Collapse
 
daxdax89 profile image
DaX

Be carefull or Instagram's robot.txt and other limits, you can easily end up banned.