0. Three Ways to Crawl Instagram
There are various methods to crawl Instagram.
The following examples are written in Ruby.
1. Using Public API
Access Token Issuance
You need to create a developer account, register an app, and obtain an access token.
require 'net/http'
require 'json'
access_token = '발급받은 액세스 토큰'
url = URI("https://graph.instagram.com/me?fields=id,username,followers_count&access_token=#{access_token}")
response = Net::HTTP.get(url)
data = JSON.parse(response)
follower_count = data['followers_count']
puts "팔로워 수: #{follower_count}"
Pros and Cons
Pros:
- It is an official API, so there is no risk of being blocked.
Cons:
- Requires a developer account and access token.
- Limited by request count and speed.
- Due to privacy concerns, you can only retrieve your follower count, not others' follow counts.
2. Using Web Scraping
require 'nokogiri'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
url = "https://www.instagram.com/suuu_yeony/"
driver.get(url)
doc = Nokogiri::HTML(driver.page_source)
follower_count = doc.at('button:contains("팔로워")').text
puts "#{follower_count}"
Pros and Cons
Pros:
- It is possible to retrieve other users' follower counts.
Cons:
- Risk of IP or account bans if detected.
- Stability may be compromised due to the nature of Selenium.
3. Using Private API
This method involves parsing data returned in JSON format.
Pros and Cons
Pros:
- It is possible to retrieve other users' follower counts.
- Excellent stability.
Cons:
- Risk of IP or account bans if detected.
4. Conclusion
In addition to the methods mentioned above, there are various other ways to crawl Instagram, each suitable for different purposes.
Instagram has limitations such as only being able to retrieve data for one page without logging in.
We recommend trying out Instagram scraping with HashScraper to experience easy crawling without logging in.




