| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
# Copyright 2020-2026 Mike Fährmann |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License version 2 as |
| 7 |
# published by the Free Software Foundation. |
| 8 |
|
| 9 |
"""Extractors for https://www.furaffinity.net/""" |
| 10 |
|
| 11 |
from .common import Extractor, Message, Dispatch |
| 12 |
from .. import text, util |
| 13 |
|
| 14 |
BASE_PATTERN = r"(?:https?://)?(?:www\.|sfw\.)?(?:f[ux]|f?xfu)raffinity\.net" |
| 15 |
|
| 16 |
|
| 17 |
class FuraffinityExtractor(Extractor): |
| 18 |
"""Base class for furaffinity extractors""" |
| 19 |
category = "furaffinity" |
| 20 |
directory_fmt = ("{category}", "{user!l}") |
| 21 |
filename_fmt = "{id}{title:? //}.{extension}" |
| 22 |
archive_fmt = "{id}" |
| 23 |
cookies_domain = ".furaffinity.net" |
| 24 |
cookies_names = ("a", "b") |
| 25 |
root = "https://www.furaffinity.net" |
| 26 |
request_interval = 1.0 |
| 27 |
_warning = True |
| 28 |
|
| 29 |
def __init__(self, match): |
| 30 |
Extractor.__init__(self, match) |
| 31 |
self.user = match[1] |
| 32 |
self.offset = 0 |
| 33 |
|
| 34 |
def _init(self): |
| 35 |
self.external = self.config("external", False) |
| 36 |
|
| 37 |
if self.config("descriptions") == "html": |
| 38 |
self._process_description = str.strip |
| 39 |
if self.config("comments") == "html": |
| 40 |
self._process_comment = str.strip |
| 41 |
|
| 42 |
layout = self.config("layout") |
| 43 |
if layout and layout != "auto": |
| 44 |
self._new_layout = False if layout == "old" else True |
| 45 |
else: |
| 46 |
self._new_layout = None |
| 47 |
|
| 48 |
if self._warning: |
| 49 |
if not self.cookies_check(self.cookies_names): |
| 50 |
self.log.warning("no 'a' and 'b' session cookies set") |
| 51 |
FuraffinityExtractor._warning = False |
| 52 |
|
| 53 |
def items(self): |
| 54 |
metadata = self.metadata() |
| 55 |
for post_id in util.advance(self.posts(), self.offset): |
| 56 |
if post := self._parse_post(post_id): |
| 57 |
if metadata: |
| 58 |
post.update(metadata) |
| 59 |
url = post.pop("url") |
| 60 |
yield Message.Directory, "", post |
| 61 |
yield Message.Url, url, post |
| 62 |
|
| 63 |
if self.external: |
| 64 |
for url in text.extract_iter( |
| 65 |
post["_description"], 'href="http', '"'): |
| 66 |
yield Message.Queue, "http" + url, post |
| 67 |
|
| 68 |
def metadata(self): |
| 69 |
return None |
| 70 |
|
| 71 |
def skip_files(self, num): |
| 72 |
self.offset += num |
| 73 |
return num |
| 74 |
|
| 75 |
def _parse_post(self, post_id): |
| 76 |
url = f"{self.root}/view/{post_id}/" |
| 77 |
page = self.request(url).text |
| 78 |
extr = text.extract_from(page) |
| 79 |
|
| 80 |
if self._new_layout is None: |
| 81 |
self._new_layout = ("http-equiv=" not in extr("<meta ", ">")) |
| 82 |
|
| 83 |
pos = page.find(">Download<") |
| 84 |
if pos < 0: |
| 85 |
msg = text.remove_html( |
| 86 |
extr('System Message', '</section>') or |
| 87 |
extr('System Message', '</table>') |
| 88 |
).partition(" . Continue ")[0] |
| 89 |
return self.log.warning( |
| 90 |
"Unable to download post %s (\"%s\")", post_id, msg) |
| 91 |
|
| 92 |
pi = text.parse_int |
| 93 |
rh = text.remove_html |
| 94 |
|
| 95 |
path = text.rextr(page, 'href="', '"', pos) |
| 96 |
data = text.nameext_from_url(path, { |
| 97 |
"id" : pi(post_id), |
| 98 |
"url": "https:" + path, |
| 99 |
}) |
| 100 |
|
| 101 |
if self._new_layout: |
| 102 |
data["scraps"] = ("/scraps/" in extr( |
| 103 |
'class="minigallery-title', '</a>')) |
| 104 |
data["artist_url"] = extr('displayName" title=" ', ' "').strip() |
| 105 |
data["artist"] = extr('>', '<') |
| 106 |
data["_description"] = extr('user-submitted-links">', '</section>') |
| 107 |
data["views"] = pi(rh(extr('title="Views">', '</div>'))) |
| 108 |
# data["comments"] = pi(rh(extr('title="Comments">', '</div>'))) |
| 109 |
data["favorites"] = pi(rh(extr('title="Favorites">', '</div>'))) |
| 110 |
data["rating"] = extr('inline c-contentRating--', '"') |
| 111 |
info = text.split_html(extr('<span class="highlight">', '</div>')) |
| 112 |
size = len(info) >> 1 |
| 113 |
info = {info[i].lower(): info[i + size] for i in range(size)} |
| 114 |
width, _, height = info.get("resolution", "").partition("x") |
| 115 |
data["fa_category"] = info.get("category", "") |
| 116 |
data["fa_subcategory"] = info.get("theme", "") |
| 117 |
data["species"] = info.get("species", "") |
| 118 |
data["width"] = pi(width) |
| 119 |
data["height"] = pi(height) |
| 120 |
data["size"] = text.parse_bytes(info.get("file size", "")[:-1]) |
| 121 |
data["tags"] = text.split_html(extr('>Keywords</div>', '</div>')) |
| 122 |
data["folders"] = [ |
| 123 |
name |
| 124 |
for folder in extr( |
| 125 |
'>Folders</div>', |
| 126 |
'<div class="comments-list">').split('</a>') |
| 127 |
if (name := rh(folder)) |
| 128 |
] |
| 129 |
data["comments"] = self._extract_comments(extr( |
| 130 |
'id="comments-submission"', '<script type="text/javascript">')) |
| 131 |
data["title"] = text.unescape(extr('data-artwork-title="', '"')) |
| 132 |
else: |
| 133 |
# old site layout |
| 134 |
data["scraps"] = ( |
| 135 |
"/scraps/" in extr('class="minigallery-title', "</a>")) |
| 136 |
data["title"] = text.unescape(extr("<h2>", "</h2>")) |
| 137 |
data["artist_url"] = extr('title="', '"').strip() |
| 138 |
data["artist"] = extr(">", "<") |
| 139 |
data["fa_category"] = extr("<b>Category:</b>", "<").strip() |
| 140 |
data["theme"] = extr("<b>Theme:</b>", "<").strip() |
| 141 |
data["species"] = extr("<b>Species:</b>", "<").strip() |
| 142 |
data["gender"] = extr("<b>Gender:</b>", "<").strip() |
| 143 |
data["favorites"] = pi(extr("<b>Favorites:</b>", "<")) |
| 144 |
# data["comments"] = pi(extr("<b>Comments:</b>", "<")) |
| 145 |
data["views"] = pi(extr("<b>Views:</b>", "<")) |
| 146 |
data["width"] = pi(extr("<b>Resolution:</b>", "x")) |
| 147 |
data["height"] = pi(extr("", "<")) |
| 148 |
data["tags"] = text.split_html(extr( |
| 149 |
'id="keywords">', '</div>'))[::2] |
| 150 |
data["rating"] = extr('<img alt="', ' ') |
| 151 |
data["_description"] = extr( |
| 152 |
'<td valign="top" align="left" width="70%" class="alt1" ' |
| 153 |
'style="padding:8px">', ' </td>') |
| 154 |
data["comments"] = self._extract_comments(extr( |
| 155 |
"<b>User comments</b>", '<script type="text/javascript">')) |
| 156 |
data["folders"] = () # folders not present in old layout |
| 157 |
|
| 158 |
data["user"] = self.user or data["artist_url"] |
| 159 |
data["date"] = self.parse_timestamp(data["filename"].partition(".")[0]) |
| 160 |
data["description"] = self._process_description(data["_description"]) |
| 161 |
data["thumbnail"] = (f"https://t.furaffinity.net/{post_id}@600-" |
| 162 |
f"{path.rsplit('/', 2)[1]}.jpg") |
| 163 |
return data |
| 164 |
|
| 165 |
def _parse_journal(self, post_id): |
| 166 |
url = f"{self.root}/journal/{post_id}/" |
| 167 |
page = self.request(url).text |
| 168 |
extr = text.extract_from(page) |
| 169 |
|
| 170 |
if self._new_layout is None: |
| 171 |
self._new_layout = ("http-equiv=" not in extr("<meta ", ">")) |
| 172 |
|
| 173 |
if msg := (extr(">System Message", "</section>") or |
| 174 |
extr("System Message", "</table>")): |
| 175 |
msg = text.remove_html(msg).partition(" . Continue ")[0] |
| 176 |
return self.log.warning("Unable to download journal %s (\"%s\")", |
| 177 |
post_id, msg) |
| 178 |
|
| 179 |
data = { |
| 180 |
"id": text.parse_int(post_id), |
| 181 |
"extension": "htm", |
| 182 |
} |
| 183 |
|
| 184 |
if self._new_layout: |
| 185 |
data["artist_url"] = extr('-displayName-block" href="/user/', '/"') |
| 186 |
data["artist"] = extr('-displayName">', '<') |
| 187 |
data["title"] = text.unescape(extr( |
| 188 |
'id="c-journalTitleTop__subject"><h3>', '<')) |
| 189 |
data["date"] = self.parse_timestamp(extr( |
| 190 |
'data-time="', '"')) |
| 191 |
data["rating"] = extr('alt="', ' ') |
| 192 |
data["url"] = "text:" + extr( |
| 193 |
'user-submitted-links">', |
| 194 |
'</div>\n </div>') |
| 195 |
data["comments"] = self._extract_comments(extr( |
| 196 |
'id="comments-journal"', '<script type="text/javascript">')) |
| 197 |
else: |
| 198 |
data["title"] = text.unescape(extr( |
| 199 |
'<div class="no_overflow">', '<')) |
| 200 |
data["artist_url"] = extr('-userName-block" href="/user/', '/"') |
| 201 |
data["artist"] = extr('</span>', '<') |
| 202 |
data["date"] = self.parse_timestamp(extr( |
| 203 |
'data-time="', '"')) |
| 204 |
data["rating"] = None |
| 205 |
data["url"] = "text:" + extr( |
| 206 |
'<div class="journal-body">', |
| 207 |
'</div>\n </td>').strip() |
| 208 |
data["comments"] = self._extract_comments(extr( |
| 209 |
'id="page-comments"', 'id="add_comment_form"')) |
| 210 |
|
| 211 |
data["user"] = self.user or data["artist_url"] |
| 212 |
return data |
| 213 |
|
| 214 |
def _process_description(self, description): |
| 215 |
return text.unescape(text.remove_html(description, "", "")) |
| 216 |
|
| 217 |
_process_comment = _process_description |
| 218 |
|
| 219 |
def _extract_comments(self, html): |
| 220 |
extr = text.extract_from(html) |
| 221 |
|
| 222 |
results = [] |
| 223 |
if self._new_layout: |
| 224 |
while ts := extr('data-timestamp="', '"'): |
| 225 |
results.append({ |
| 226 |
"date": self.parse_timestamp(ts), |
| 227 |
"id" : extr('id="cid:', '"'), |
| 228 |
"user": extr('href="/user/', '/'), |
| 229 |
"text": self._process_comment(extr( |
| 230 |
'<div class="user-submitted-links">', |
| 231 |
'</div>\n </comment-user-text>')), |
| 232 |
}) |
| 233 |
else: |
| 234 |
while cid := extr('id="cid:', '"'): |
| 235 |
results.append({ |
| 236 |
"id" : cid, |
| 237 |
"date": self.parse_timestamp(extr( |
| 238 |
'data-timestamp="', '"')), |
| 239 |
"user": extr('href="/user/', '/'), |
| 240 |
"text": self._process_comment(extr( |
| 241 |
'class="message-text">', |
| 242 |
'</div>\n </td>\n </tr>')), |
| 243 |
}) |
| 244 |
return results |
| 245 |
|
| 246 |
def _pagination(self, path, folder=None): |
| 247 |
num = 1 |
| 248 |
folder = "" if folder is None else f"/folder/{folder}/a" |
| 249 |
|
| 250 |
while True: |
| 251 |
url = f"{self.root}/{path}/{self.user}{folder}/{num}/" |
| 252 |
page = self.request(url).text |
| 253 |
post_id = None |
| 254 |
|
| 255 |
for post_id in text.extract_iter(page, 'id="sid-', '"'): |
| 256 |
yield post_id |
| 257 |
|
| 258 |
if not post_id: |
| 259 |
return |
| 260 |
num += 1 |
| 261 |
|
| 262 |
def _pagination_favorites(self, start=None): |
| 263 |
path = f"/favorites/{self.user}/" |
| 264 |
if start is not None: |
| 265 |
path += start |
| 266 |
|
| 267 |
while path: |
| 268 |
page = self.request(self.root + path).text |
| 269 |
extr = text.extract_from(page) |
| 270 |
while True: |
| 271 |
post_id = extr('id="sid-', '"') |
| 272 |
if not post_id: |
| 273 |
break |
| 274 |
self._favorite_id = text.parse_int(extr('data-fav-id="', '"')) |
| 275 |
yield post_id |
| 276 |
|
| 277 |
pos = page.find('type="submit">Next</button>') |
| 278 |
if pos >= 0: |
| 279 |
path = text.rextr(page, '<form action="', '"', pos) |
| 280 |
continue |
| 281 |
path = text.extr(page, 'right" href="', '"') |
| 282 |
|
| 283 |
def _pagination_journals(self, pnum=None): |
| 284 |
pnum = text.parse_int(pnum, 1) |
| 285 |
path = f"/journals/{self.user}/{pnum}" |
| 286 |
while True: |
| 287 |
page = self.request(self.root + path).text |
| 288 |
extr = text.extract_from(page) |
| 289 |
while True: |
| 290 |
post_id = extr('<a href="#jid:', '"') |
| 291 |
if not post_id: |
| 292 |
break |
| 293 |
yield post_id |
| 294 |
|
| 295 |
pnum += 1 |
| 296 |
path = f"/journals/{self.user}/{pnum}/" |
| 297 |
if path not in page: |
| 298 |
break |
| 299 |
|
| 300 |
def _pagination_search(self, query): |
| 301 |
url = self.root + "/search/" |
| 302 |
data = { |
| 303 |
"page" : 1, |
| 304 |
"order-by" : "relevancy", |
| 305 |
"order-direction": "desc", |
| 306 |
"range" : "all", |
| 307 |
"range_from" : "", |
| 308 |
"range_to" : "", |
| 309 |
"rating-general" : "1", |
| 310 |
"rating-mature" : "1", |
| 311 |
"rating-adult" : "1", |
| 312 |
"type-art" : "1", |
| 313 |
"type-music" : "1", |
| 314 |
"type-flash" : "1", |
| 315 |
"type-story" : "1", |
| 316 |
"type-photo" : "1", |
| 317 |
"type-poetry" : "1", |
| 318 |
"mode" : "extended", |
| 319 |
} |
| 320 |
|
| 321 |
data.update(query) |
| 322 |
if "page" in query: |
| 323 |
data["page"] = text.parse_int(query["page"]) |
| 324 |
|
| 325 |
while True: |
| 326 |
page = self.request(url, method="POST", data=data).text |
| 327 |
post_id = None |
| 328 |
|
| 329 |
for post_id in text.extract_iter(page, 'id="sid-', '"'): |
| 330 |
yield post_id |
| 331 |
|
| 332 |
if not post_id: |
| 333 |
return |
| 334 |
|
| 335 |
if "next_page" in data: |
| 336 |
data["page"] += 1 |
| 337 |
else: |
| 338 |
data["next_page"] = "Next" |
| 339 |
|
| 340 |
|
| 341 |
class FuraffinityGalleryExtractor(FuraffinityExtractor): |
| 342 |
"""Extractor for a furaffinity user's gallery""" |
| 343 |
subcategory = "gallery" |
| 344 |
pattern = BASE_PATTERN + r"/gallery/([^/?#]+)(?:$|/(?!folder/))" |
| 345 |
example = "https://www.furaffinity.net/gallery/USER/" |
| 346 |
|
| 347 |
def posts(self): |
| 348 |
return self._pagination("gallery") |
| 349 |
|
| 350 |
|
| 351 |
class FuraffinityFolderExtractor(FuraffinityExtractor): |
| 352 |
"""Extractor for a FurAffinity folder""" |
| 353 |
subcategory = "folder" |
| 354 |
directory_fmt = ("{category}", "{user!l}", |
| 355 |
"Folders", "{folder_id}{folder_name:? //}") |
| 356 |
pattern = BASE_PATTERN + r"/gallery/([^/?#]+)/folder/(\d+)(?:/([^/?#]+))?" |
| 357 |
example = "https://www.furaffinity.net/gallery/USER/folder/12345/FOLDER" |
| 358 |
|
| 359 |
def metadata(self): |
| 360 |
return { |
| 361 |
"folder_id" : self.groups[1], |
| 362 |
"folder_name": self.groups[2] or "", |
| 363 |
} |
| 364 |
|
| 365 |
def posts(self): |
| 366 |
return self._pagination("gallery", self.groups[1]) |
| 367 |
|
| 368 |
|
| 369 |
class FuraffinityScrapsExtractor(FuraffinityExtractor): |
| 370 |
"""Extractor for a furaffinity user's scraps""" |
| 371 |
subcategory = "scraps" |
| 372 |
directory_fmt = ("{category}", "{user!l}", "Scraps") |
| 373 |
pattern = BASE_PATTERN + r"/scraps/([^/?#]+)" |
| 374 |
example = "https://www.furaffinity.net/scraps/USER/" |
| 375 |
|
| 376 |
def posts(self): |
| 377 |
return self._pagination("scraps") |
| 378 |
|
| 379 |
|
| 380 |
class FuraffinityFavoriteExtractor(FuraffinityExtractor): |
| 381 |
"""Extractor for a furaffinity user's favorites""" |
| 382 |
subcategory = "favorite" |
| 383 |
directory_fmt = ("{category}", "{user!l}", "Favorites") |
| 384 |
pattern = BASE_PATTERN + r"/favorites/([^/?#]+)(/\d+/(?:next|prev))?" |
| 385 |
example = "https://www.furaffinity.net/favorites/USER/" |
| 386 |
|
| 387 |
def posts(self): |
| 388 |
return self._pagination_favorites(self.groups[1]) |
| 389 |
|
| 390 |
def _parse_post(self, post_id): |
| 391 |
if post := FuraffinityExtractor._parse_post(self, post_id): |
| 392 |
post["favorite_id"] = self._favorite_id |
| 393 |
return post |
| 394 |
|
| 395 |
|
| 396 |
class FuraffinityJournalsExtractor(FuraffinityExtractor): |
| 397 |
"""Extractor for a furaffinity user's journal entries""" |
| 398 |
subcategory = "journals" |
| 399 |
directory_fmt = ("{category}", "{user!l}", "Journals") |
| 400 |
archive_fmt = "j_{id}" |
| 401 |
pattern = BASE_PATTERN + r"/journals/([^/?#]+)(/\d+)?" |
| 402 |
example = "https://www.furaffinity.net/journals/USER/" |
| 403 |
|
| 404 |
def posts(self): |
| 405 |
return self._pagination_journals(self.groups[1]) |
| 406 |
|
| 407 |
_parse_post = FuraffinityExtractor._parse_journal |
| 408 |
|
| 409 |
|
| 410 |
class FuraffinitySearchExtractor(FuraffinityExtractor): |
| 411 |
"""Extractor for furaffinity search results""" |
| 412 |
subcategory = "search" |
| 413 |
directory_fmt = ("{category}", "Search", "{search}") |
| 414 |
pattern = BASE_PATTERN + r"/search(?:/([^/?#]+))?/?[?&]([^#]+)" |
| 415 |
example = "https://www.furaffinity.net/search/?q=QUERY" |
| 416 |
|
| 417 |
def __init__(self, match): |
| 418 |
FuraffinityExtractor.__init__(self, match) |
| 419 |
self.query = text.parse_query(match[2]) |
| 420 |
if self.user and "q" not in self.query: |
| 421 |
self.query["q"] = text.unquote(self.user) |
| 422 |
|
| 423 |
def metadata(self): |
| 424 |
return {"search": self.query.get("q")} |
| 425 |
|
| 426 |
def posts(self): |
| 427 |
return self._pagination_search(self.query) |
| 428 |
|
| 429 |
|
| 430 |
class FuraffinityPostExtractor(FuraffinityExtractor): |
| 431 |
"""Extractor for individual posts on furaffinity""" |
| 432 |
subcategory = "post" |
| 433 |
pattern = BASE_PATTERN + r"/(?:view|full)/(\d+)" |
| 434 |
example = "https://www.furaffinity.net/view/12345/" |
| 435 |
|
| 436 |
def posts(self): |
| 437 |
post_id = self.user |
| 438 |
self.user = None |
| 439 |
return (post_id,) |
| 440 |
|
| 441 |
|
| 442 |
class FuraffinityJournalExtractor(FuraffinityExtractor): |
| 443 |
"""Extractor for a single furaffinity journal""" |
| 444 |
subcategory = "journal" |
| 445 |
directory_fmt = FuraffinityJournalsExtractor.directory_fmt |
| 446 |
archive_fmt = FuraffinityJournalsExtractor.archive_fmt |
| 447 |
pattern = BASE_PATTERN + r"/journal/(\d+)" |
| 448 |
example = "https://www.furaffinity.net/journal/12345/" |
| 449 |
|
| 450 |
posts = FuraffinityPostExtractor.posts |
| 451 |
_parse_post = FuraffinityExtractor._parse_journal |
| 452 |
|
| 453 |
|
| 454 |
class FuraffinityUserExtractor(Dispatch, FuraffinityExtractor): |
| 455 |
"""Extractor for furaffinity user profiles""" |
| 456 |
pattern = BASE_PATTERN + r"/user/([^/?#]+)" |
| 457 |
example = "https://www.furaffinity.net/user/USER/" |
| 458 |
|
| 459 |
def items(self): |
| 460 |
base = self.root |
| 461 |
user = self.user + "/" |
| 462 |
return self._dispatch_extractors(( |
| 463 |
(FuraffinityGalleryExtractor , f"{base}/gallery/{user}"), |
| 464 |
(FuraffinityScrapsExtractor , f"{base}/scraps/{user}"), |
| 465 |
(FuraffinityFavoriteExtractor, f"{base}/favorites/{user}"), |
| 466 |
(FuraffinityJournalsExtractor, f"{base}/journals/{user}"), |
| 467 |
), ("gallery",)) |
| 468 |
|
| 469 |
|
| 470 |
class FuraffinityFollowingExtractor(FuraffinityExtractor): |
| 471 |
"""Extractor for a furaffinity user's watched users""" |
| 472 |
subcategory = "following" |
| 473 |
pattern = BASE_PATTERN + "/watchlist/by/([^/?#]+)" |
| 474 |
example = "https://www.furaffinity.net/watchlist/by/USER/" |
| 475 |
|
| 476 |
def items(self): |
| 477 |
url = f"{self.root}/watchlist/by/{self.user}/" |
| 478 |
data = {"_extractor": FuraffinityUserExtractor} |
| 479 |
|
| 480 |
while True: |
| 481 |
page = self.request(url).text |
| 482 |
|
| 483 |
for path in text.extract_iter(page, '<a href="', '"'): |
| 484 |
yield Message.Queue, self.root + path, data |
| 485 |
|
| 486 |
path = text.rextr(page, 'action="', '"') |
| 487 |
if url.endswith(path): |
| 488 |
return |
| 489 |
url = self.root + path |
| 490 |
|
| 491 |
|
| 492 |
class FuraffinitySubmissionsExtractor(FuraffinityExtractor): |
| 493 |
"""Extractor for new furaffinity submissions""" |
| 494 |
subcategory = "submissions" |
| 495 |
pattern = BASE_PATTERN + r"(/msg/submissions(?:/[^/?#]+)?)" |
| 496 |
example = "https://www.furaffinity.net/msg/submissions" |
| 497 |
|
| 498 |
def posts(self): |
| 499 |
self.user = None |
| 500 |
url = self.root + self.groups[0] |
| 501 |
return self._pagination_submissions(url) |
| 502 |
|
| 503 |
def _pagination_submissions(self, url): |
| 504 |
while True: |
| 505 |
page = self.request(url).text |
| 506 |
|
| 507 |
for post_id in text.extract_iter(page, 'id="sid-', '"'): |
| 508 |
yield post_id |
| 509 |
|
| 510 |
if (pos := page.find(">Next 48</a>")) < 0 and \ |
| 511 |
(pos := page.find(">>>> Next 48 >>")) < 0: |
| 512 |
return |
| 513 |
|
| 514 |
path = text.rextr(page, 'href="', '"', pos) |
| 515 |
url = self.root + text.unescape(path) |