Skip to content

Commit

Permalink
Update docstring of ProfileLooter.pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Larralde committed Apr 3, 2018
1 parent e6384c1 commit 0951368
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions instalooter/looters.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ def _cachefs(cls):

@CachedClassProperty
@classmethod
def _user_agent(cls):
def _user_agents(cls):
"""~fake_useragent.UserAgent: a collection of fake user-agents.
"""
filename = 'fake_useragent_{}.json'.format(fake_useragent.VERSION)
ua = fake_useragent.UserAgent(path=cls._cachefs.getsyspath(filename))
return ua.firefox
return fake_useragent.UserAgent(
path=cls._cachefs.getsyspath(filename),
safe_attrs=['__name__', '__objclass__'])

# str: The name of the cookie file in the cache filesystem
_COOKIE_FILE = "cookies.txt"
Expand Down Expand Up @@ -119,7 +120,7 @@ def _login(cls, username, password, session=None):
'Host': 'www.instagram.com',
'Origin': 'https://www.instagram.com',
'Referer': 'https://www.instagram.com',
'User-Agent': cls._user_agent,
'User-Agent': cls._user_agents.firefox,
'X-Instagram-AJAX': '1',
'X-Requested-With': 'XMLHttpRequest'
})
Expand Down Expand Up @@ -667,8 +668,20 @@ def __init__(self, username, **kwargs):
self._username = username
self._owner_id = None

def pages(self): # noqa: D102
def pages(self):
# type: () -> ProfileIterator
"""Obtain an iterator over Instagram post pages.
Returns:
PageIterator: an iterator over the instagram post pages.
Raises:
ValueError: when the requested user does not exist.
RuntimeError: when the user is a private account
and there is no logged user (or the logged user
does not follow that account).
"""
if self._owner_id is None:
it = ProfileIterator.from_username(self._username, self.session)
self._owner_id = it.owner_id
Expand Down

0 comments on commit 0951368

Please sign in to comment.