The InstaClient
classο
- InstaTweet.instaclient.USER_AGENTο
Hardcoded user agent proven to work with the
get_user()
endpoint- Version Added
v2.0.0b13
- InstaClient.DOWNLOAD_DIRο
[Optional] β Directory to temporarily download media to
- class InstaTweet.instaclient.InstaClient(session_id, user_agent=USER_AGENT, proxies=None)[source]View on GitHubο
Bases:
object
Minimalistic class for scraping/downloading Instagram user/media data
- __init__(session_id, user_agent=USER_AGENT, proxies=None)[source]View on GitHubο
Initialize an
InstaClient
with an Instagram sessionid cookie (at minimum)Note
As of v2.0.0b13, the endpoint used by
get_user()
seems to require a specificUSER_AGENT
You can override the hardcoded one if youβd like, but youβll likely get a"useragent mismatch"
response
- request(url)[source]View on GitHubο
Sends a request using the
cookies
,headers
, andproxies
- Parameters
url (str) β the Instagram URL to send the request to
- Return type
Response
- scrape(page)[source]View on GitHubο
Scrapes an Instagram page and wraps the response data
- get_hashtag(tag, max_id='')[source]View on GitHubο
Scrapes an Instagram hashtag and wraps the response with
Hashtag
- get_user(username)[source]View on GitHubο
Scrapes an Instagram userβs profile and wraps the response with
InstaUser
- get_post(shortcode)[source]View on GitHubο
Scrapes an Instagram post by shortcode or URL
- get_username(user_id)[source]View on GitHubο
Retrieves the Instagram username for the user with the provided
user_id
Tip
Use this with
get_user()
to scrape byuser_id
:>> user_id = 51276430399 >> username = insta.get_username(user_id) >> user = insta.get_user(username) >> print(user.posts[0])
Post 2981866202934977614 by @dailykittenig on 2022-11-29 01:44:37
- download_post(post, filepath=None)[source]View on GitHubο
Downloads the media from an Instagram post