
TL;DR: We built open-source Python code that extracts Instagram profiles, posts, reels and comments, then tested it head to head against Apify’s Instagram Scraper. On 1,200 comments it was 32x cheaper. On deep collection runs of more than 15,000 comments and replies it was up to 75x cheaper. Its output shared 98.5% or more of the same comment IDs as Apify’s.
Why we built it
Our cloud browsers benchmark showed which browsers get past the most aggressive bot protection on the web. Getting onto the page is only half the job, though. Next we wanted to build something people can actually use.
We picked Apify’s Instagram Scraper, an industry standard, and set out to build an open-source alternative that matches its data quality, costs less to run and gives developers full control over the code. The browser infrastructure, proxy rotation and anti-bot handling are taken care of by the cloud browser, so you run the code and get the data.
What data can it extract?
The Python code runs from your command line or inside your own backend. Give it a list of URLs, usernames or search queries and it collects:
| Target | What you get |
|---|---|
| Profiles | Bio, follower and following counts, profile pictures and account details |
| Posts and reels | Captions, dates, engagement stats, media URLs and carousel items |
| Comments and replies | Text, authors, timestamps, likes and full reply threads |
| Stories | Active story items, timestamps and media URLs |
| Tagged posts | Posts where the target account is tagged |
| Search and locations | Hashtags, location details and their posts |
You can export the results as JSON, JSONL or CSV. To make switching easy, we kept familiar settings such as directUrls, resultsType and resultsLimit, so an Apify-style input payload works out of the box.
How it works
You don’t run dozens of Chrome containers or manage proxies. The browser sessions run remotely, and your Python script tells them what to do:
- You set the inputs and limits.
- A cloud browser opens the Instagram pages.
- The code reads the structured responses from Instagram’s internal APIs.
- Progress is saved as it goes.
- The results are exported as JSON or CSV.
The key step is the third one. Instead of rendering each page and reading HTML elements one by one, the code picks up the structured data Instagram already uses under the hood. Reading those internal API responses directly is faster, more reliable and much cheaper. If that route isn’t available, it falls back to the rendered page content or to optional AI data extraction.
The hardest part was comments. At first we could collect only 15 comments before the page stopped loading more. By reading the page’s network traffic instead of the interface, we collected about 16,000 comments from 12 posts.
Resumable runs: no more lost data
Anyone who collects data at scale knows the pain: a run goes well for hours, hits an unexpected error, crashes and loses everything.
This code has a resumable collection mode. It saves records and pagination state locally as it goes. If a run is interrupted, restart it and point it at the saved run directory. It reads its checkpoint, skips duplicates and picks up where it left off, so you keep the data you already paid to collect.
The test: our open-source code vs Apify
To keep it fair, we gave both tools the same job:
- Target: 12 Instagram post URLs.
- Goal: 100 parent comments per post, 1,200 records in total, without replies.
- Our setup: one logged-in cloud browser session, with traffic through lite proxies in Germany.
- Apify setup: the actor with default settings, run twice to check that its own comments matched between runs.

Cost: 32x cheaper
Here’s what each run cost to extract the same 1,200 comments:
| Run | Records | Total cost | Cost per 1,000 records |
|---|---|---|---|
| Apify (run 1) | 1,200 | $2.76 | $2.30 |
| Apify (run 2) | 1,200 | $2.76 | $2.30 |
| Open-source code on a cloud browser | 1,200 | $0.086 | $0.072 |
Our recorded bill for the run was $0.086, about $0.072 per 1,000 comments, including browser time and proxy traffic. Apify charged $2.76, so our code was roughly 32 times cheaper for this batch.
The difference comes from the pricing model. Apify charges per record collected, about $2.30 per 1,000 items. A cloud browser bills only for browser time and proxy bandwidth, so at scale you pay for compute instead of a markup on every row.
Did the data match?
Yes. Our output shared 98.50% to 98.75% of the exact same comment IDs as Apify’s exports.
Why not 100%? Instagram’s feed shifts all the time. Even Apify’s own two runs, minutes apart, didn’t match perfectly. An overlap above 98.5% is normal for live social media data and confirms both tools were collecting the same comments.
Scaling up: deep collection and parallel sessions
Small batches are good for testing, but what happens at volume? We ran deep collection jobs of more than 15,800 comments and replies. We also ran the code in parallel across two browser sessions, each with its own proxy IP and its own session cookies.
| Deep collection (15,800+ records) | Run time | Usage cost | Saving vs Apify |
|---|---|---|---|
| Apify (estimated at $2.30 per 1,000) | n/a | about $36.43 | n/a |
| 1 session, one post after another | 3 h 17 min | $0.48 | 75x cheaper |
| 2 parallel sessions | 1 h 27 min | $0.59 | 61x cheaper |
That works out at about $0.03 per 1,000 comments. Two parallel sessions cut the run time by more than half for almost the same cost, and on smaller batches a second session cut collection time by about 30% for $0.088 instead of $0.086.

Beyond comments
We also tested profiles, reels and hashtags, and matched 100% of the IDs for profiles, reels and tagged posts. Usage cost compared with Apify:
- 30 profile posts: 1.57x cheaper.
- 30 reels: 1.52x cheaper.
- 30 tagged posts: 1.29x cheaper.
- 30 hashtag posts: 2.73x cheaper.
The bigger the job, the bigger the saving. With a cloud browser you pay for browser time and bandwidth, not per record.
Source code
The whole project is open source: jsonifyco/instagram-scraper on GitHub. You can configure it for your own targets and set up several accounts for parallel collection.
It runs on bro’s cloud browsers through the bro Python SDK, so you need Python 3.10 or later, a bro API key and, for session-dependent data such as deep comment threads or stories, your Instagram cookies. Profiles, reels and posts work without cookies. The project is for educational purposes.
Let Jason run it for you
Open-source code gives you full control, and someone still has to run it, watch it and fix it when Instagram changes. If you need the data on a schedule rather than the code, Jsonify does that part. Tell Jason, our AI agent, what data you need and how often. He builds the pipeline, checks every run and repairs it when a source changes. The rows arrive in Google Sheets, Snowflake, a webhook or an API.
To see how that compares with running Actors yourself, read our page on Apify alternatives, or describe the data you need and see what Jason builds.
Frequently asked questions
What Instagram data can this code collect? Profiles, posts, reels, comments and replies, stories, tagged posts, and the content behind hashtags and locations. It also supports search and date filters. The exact fields depend on the target and on your account’s access.
Do I need Instagram cookies? It depends on the data. Public profiles, posts and reels don’t need cookies. Reply threads, stories and tagged feeds need valid cookies.
Can I extract Instagram data without logging in? Yes, for public content. A single anonymous browser hit Instagram’s login wall after 14 profiles. With 5 anonymous sessions in parallel, each on its own German proxy IP, we extracted 20 public profiles in 69 seconds without a single login wall. Deep comment threads, replies, tagged grids and stories need a logged-in session, so pass session cookies to your browsers.
What happens if a long run gets interrupted? You don’t lose your progress. The code keeps a checkpoint for every browser session and saves records to SQLite and JSONL files. When you restart, it picks up where it left off instead of spending time and proxy data on posts it already collected.
Can I use a different browser service? Yes. The source code is open, and you can connect it to another browser service or a local Chrome if you adapt the browser integration.
Do I need to run a browser locally? No. Your Python project controls a remote browser through the SDK, so you don’t need Chrome installed.
What does it cost to run? You pay only for the browser time and proxy traffic your sessions use. In our tests that was $0.086 for 1,200 comments and $0.48 for more than 15,800 comments and replies. Start with a small sample to measure the cost of your own workload.