Skip to content

Commit

Permalink
Fix r.html.next() for next url
Browse files Browse the repository at this point in the history
  • Loading branch information
oldani authored and pigna90 committed Sep 19, 2018
1 parent 69bc5dc commit 3d6b828
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions requests_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def __init__(self, *, session: Union['HTMLSession', 'AsyncHTMLSession'] = None,
def __repr__(self) -> str:
return f"<HTML url={self.url!r}>"

def _next(self, fetch: bool = False, next_symbol: _NextSymbol = DEFAULT_NEXT_SYMBOL) -> _Next:
def next(self, fetch: bool = False, next_symbol: _NextSymbol = DEFAULT_NEXT_SYMBOL) -> _Next:
"""Attempts to find the next page, if there is one. If ``fetch``
is ``True`` (default), returns :class:`HTML <HTML>` object of
next page. If ``fetch`` is ``False``, simply returns the next URL.
Expand Down Expand Up @@ -478,19 +478,19 @@ def __iter__(self):
while True:
yield next
try:
next = next._next(fetch=True, next_symbol=self.next_symbol).html
next = next.next(fetch=True, next_symbol=self.next_symbol).html
except AttributeError:
break

def __next__(self):
return self._next(fetch=True, next_symbol=self.next_symbol).html
return self.next(fetch=True, next_symbol=self.next_symbol).html

def __aiter__(self):
return self

async def __anext__(self):
while True:
url = self._next(fetch=False, next_symbol=self.next_symbol)
url = self.next(fetch=False, next_symbol=self.next_symbol)
if not url:
break
response = await self.session.get(url)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_pagination():


@pytest.mark.asyncio
async def test_pagination(event_loop):
async def test_async_pagination(event_loop):
asession = AsyncHTMLSession()
pages = (
'https://xkcd.com/1957/',
Expand Down

0 comments on commit 3d6b828

Please sign in to comment.