Fix r.html.next() for next url

This commit is contained in:
Ordanis Sanchez
2018-03-21 19:06:37 -04:00
parent fc1fabd8dc
commit 09c7b683cc
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -430,7 +430,7 @@ class HTML(BaseParser):
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.
@@ -478,19 +478,19 @@ class HTML(BaseParser):
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)
+1 -1
View File
@@ -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/',