DEV Community

Steffan Jensen
Steffan Jensen

Posted on • Edited on

1 1

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")
Enter fullscreen mode Exit fullscreen mode

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

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top 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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️