mirror of
https://github.com/simon987/chan_feed.git
synced 2025-04-10 14:06:42 +00:00
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from vanwanet_scrape.scraper import Scraper
|
|
|
|
from chan.chan_json import JsonChanHelper
|
|
from hexlib.log import logger
|
|
|
|
|
|
class JsonKunChanHelper(JsonChanHelper):
|
|
|
|
@staticmethod
|
|
def item_type(item):
|
|
return "thread" if item["resto"] == 0 else "post"
|
|
|
|
def __init__(self, db_id, base_url, image_url, thread_path, image_path, boards):
|
|
super().__init__(db_id, base_url, image_url, thread_path, image_path, boards)
|
|
|
|
self._scraper = Scraper(
|
|
headers={
|
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0",
|
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
"Referer": "https://8kun.top/index.html"
|
|
},
|
|
domains=[
|
|
"8kun.top",
|
|
"media.8kun.top",
|
|
"sys.8kun.net"
|
|
],
|
|
logger=logger
|
|
)
|
|
|
|
self.get_method = self._scraper.get
|
|
|
|
def image_url(self, board, tim, extension):
|
|
return "%s%s%s%s" % (self._image_url, self._image_path, tim, extension)
|