34 lines
952 B
Python
Raw Normal View History

2015-12-03 00:50:34 +01:00
# -*- coding: utf-8 -*-
2016-10-01 15:54:27 +02:00
# Copyright 2015, 2016 Mike Fährmann
2015-12-03 00:50:34 +01:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
2016-10-01 15:54:27 +02:00
"""Recursive extractor"""
2015-12-03 00:50:34 +01:00
import re
from .common import Extractor, Message
from .. import adapter
2015-12-03 00:50:34 +01:00
2017-02-01 00:53:19 +01:00
2016-10-01 15:54:27 +02:00
class RecursiveExtractor(Extractor):
2015-12-03 00:50:34 +01:00
2016-10-01 15:54:27 +02:00
category = "recursive"
pattern = ["r(?:ecursive)?:(.+)"]
test = [("recursive:https://pastebin.com/raw/FLwrCYsT", {
"url": "eee86d65c346361b818e8f4b2b307d9429f136a2",
})]
2015-12-03 00:50:34 +01:00
def __init__(self, match):
Extractor.__init__(self)
self.session.mount("file://", adapter.FileAdapter())
2015-12-03 00:50:34 +01:00
self.url = match.group(1)
def items(self):
page = self.request(self.url).text
yield Message.Version, 1
2016-10-01 15:54:27 +02:00
for match in re.finditer(r"https?://[^\s\"']+", page):
2015-12-03 00:50:34 +01:00
yield Message.Queue, match.group(0)