Skip to content

LucaBarile/InstagramPostFinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instagram Post Finder (IGPF)

Disclaimer ⚠️

IGPF doesn't belong or is related to the official Instagram application\website in any way; I developed it as an independent and unofficial application.
Responsibility for consequences of using this application remains with the user; I'm not responsible for how you use it.
Instagram has gotten increasingly strict with scraping; use the application responsibly and respectfully.

Premise 📢

At the time of writing (2023-03-23) IGPF has been successfully tested but, as has already happened in the past, Instagram may change its APIs again, and it may no longer work (or may work partially).
If this were to happen, adapting the application to the new APIs shouldn't be very complicated, unless the changes made by Instagram were radical. The pieces of code to fix will probably be those that allow IGPF to get the user's JSON files from URL, and those related to their parsing.

What is it for? 🤔

It is an Android application designed to search public posts of an Instagram user by keyword, and you don't need to have an Instagram account to use it.
Since, at the time of writing, Instagram doesn't allow its users to make public only some posts if they have a private account, this application can only be used to search posts of a user who have a public Instagram account.

How it works? ⚙️

Once the Instagram username and the keyword have been entered, IGPF will list all the links to the user's posts whose caption contains the keyword.

About the keyword:
  • If the keyword is contained in another word (e.g. keyword = example and word = counterexamples), it will still be recognized.
  • Keyword searching is case insensitive (e.g. keyword = hello and word = HeLLo is equivalent to keyword = hello and word = hello).
  • The keyword can contain any symbol (therefore, for example, it can also be an hashtag), with the exception of spaces (otherwise you would be entering several keywords and not just one).

If matches are found (listed as Instagram image shortcodes), just tap on one to view the matching post and its caption. The post will be shown through your device’s default browser (or through the Instagram app (if it's installed)).

Demo 🎦

Username of the Instagram user with public profile: barol92.
Keyword: #budapest.
Expected result: IGPF will list all the links to the barol92's posts whose caption contains #budapest.

Instagram put a limit on the number of requests ⛔

Whenever you want to search public posts of an Instagram user by keyword, IGPF makes several HTTP GET requests to Instagram, depending on the number of posts that the user has published; the more there are, the more requests it must make.
If the requests don't come from a logged-in Instagram user (as in the case of IGPF, which doesn't require any login to Instagram (and consequently doesn't have any Instagram Access Token)), Instagram, after a certain number of requests, will temporarily block the IP address where the requests come from.
Instagram typically unblocks the IP address within 24 hours (from tests I've done there doesn't seem to be an exact number of hours; it often changed from test to test), but it is possible to bypass the block. If your device is connected to the wireless network you can change its IP address by connecting it to the mobile network (and vice versa), as shown below.

The offline mode 📴

IGPF saves user's posts data locally after downloading.
IGPF avoids re-downloading user's posts data if they have already been downloaded in the current day; searches for matches by directly analyzing the already downloaded data.

IGPF only downloads the user's posts data in the following two cases:
  1. The user's posts data have never been downloaded.
  2. The user's posts data were downloaded at least a day ago (this means that the user may have published new posts that need to be analyzed). In this case the old data will be overwritten with new ones.

If the device can't connect to the Internet or an error occurs while downloading the user's posts data, IGPF searches for matches analyzing the already downloaded data (if any), even if they're not up to date (better than nothing... 🤷).

This way of proceeding has the following advantages:

  • There's no need to wait for user's posts data to download, so matches are found much faster.
  • You can search for matches when your device is offline and view them when it's online.
  • Instead of exhausting the maximum number of HTTP GET requests we can make to Instagram downloading the users posts data that we already have, we can download the user's posts data that we don't have yet.

The only case in which it will not be possible to find matches is when the device is not online and the user's posts data were never downloaded (or in case there're no matches, of course...).

The IGPF logic 👨‍💻

Easter egg 🥚

IGPF contains an easter egg; find it! 🔍
Fiddle around with the graphical interface of the app to find it, and if you can't find it and want to give up, take a look at the code, I wrote a comment to locate it.

Download links 📥

Here you can download the Android project.
Here you can download the APK.

Credits 🙏

  • Dan for this useful tool.
  • Neeraj Mishra for this article about JSON parsing.
  • Tim Großmann for the list of query IDs to use via GraphQL.
  • Carlos Henrique Reis for this article about getting data from a public Instagram profile.
  • The Stack Overflow community for helping me to solve some programming problems.
  • The beta testers Fabio Scaravelli and Davide Barbieri.

Here you can visit my website 🌐
Here you can buy me a unicorn 🦄
Share the Knowledge!