The hell of data collection, Instagram? Break through it with these three methods!

Introduction to methods of collecting Instagram data, their advantages and disadvantages, official API, web scraping, and how to use Private API.

4
The hell of data collection, Instagram? Break through it with these three methods!

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.

Comments

Add Comment

Your email won't be published and will only be used for reply notifications.

Continue Reading

Get notified of new posts

We'll email you when 해시스크래퍼 기술 블로그 publishes new content.

Your email will only be used for new post notifications.