📜  在Python中使用 Instagramy 抓取 Instagram

📅  最后修改于: 2022-05-13 01:54:34.553000             🧑  作者: Mango

在Python中使用 Instagramy 抓取 Instagram

在本文中,我们将学习如何使用网页抓取获取 Instagram 个人资料详细信息。 Python为网页抓取提供了强大的工具,我们将在这里使用 Instagramy。该工具专为 Instagram 制作,还使用 Pandas 分析数据。

安装

Python包Instagramy用于快速轻松地抓取 Instagram。这个包是通过运行以下命令安装的。它会根据网络连接为您抓取数据。

pip install instagramy

示例 1:抓取基本细节

Python3
from instagramy import Instagram
 
 
# Connecting the profile
user = Instagram("geeks_for_geeks")
 
# printing the basic details like
# followers, following, bio
print(user.is_verified())
print(user.popularity())
print(user.get_biography())
 
# return list of dicts
posts = user.get_posts_details()
 
print('\n\nLikes', 'Comments')
for post in posts:
    likes = post["likes"]
    comments = post["comment"]
    print(likes,comments)


Python3
from instagramy import Instalysis
 
# Instagram user_id of ipl teams
teams = ["chennaiipl", "mumbaiindians",
         "royalchallengersbangalore", "kkriders",
         "delhicapitals", "sunrisershyd",
         "kxipofficial"]
 
data = Instalysis(teams)
 
# return the dataframe
data_frame = data.analysis()
data_frame


输出:

示例 2:分析数据

蟒蛇3

from instagramy import Instalysis
 
# Instagram user_id of ipl teams
teams = ["chennaiipl", "mumbaiindians",
         "royalchallengersbangalore", "kkriders",
         "delhicapitals", "sunrisershyd",
         "kxipofficial"]
 
data = Instalysis(teams)
 
# return the dataframe
data_frame = data.analysis()
data_frame

输出: