| 438 | """ |
| 439 | |
| 440 | def get_next(): |
| 441 | candidates = self.find('a', containing=next_symbol) |
| 442 | |
| 443 | for candidate in candidates: |
| 444 | if candidate.attrs.get('href'): |
| 445 | # Support 'next' rel (e.g. reddit). |
| 446 | if 'next' in candidate.attrs.get('rel', []): |
| 447 | return candidate.attrs['href'] |
| 448 | |
| 449 | # Support 'next' in classnames. |
| 450 | for _class in candidate.attrs.get('class', []): |
| 451 | if 'next' in _class: |
| 452 | return candidate.attrs['href'] |
| 453 | |
| 454 | if 'page' in candidate.attrs['href']: |
| 455 | return candidate.attrs['href'] |
| 456 | |
| 457 | try: |
| 458 | # Resort to the last candidate. |
| 459 | return candidates[-1].attrs['href'] |
| 460 | except IndexError: |
| 461 | return None |
| 462 | |
| 463 | __next = get_next() |
| 464 | if __next: |