fix bookmarklet

This commit is contained in:
smilerz
2022-07-06 16:16:53 -05:00
parent 946de2e7e3
commit e23d514d89
4 changed files with 65 additions and 55 deletions

View File

@@ -1,6 +1,7 @@
from bs4 import BeautifulSoup
from json import JSONDecodeError
from recipe_scrapers import SCRAPERS
from bs4 import BeautifulSoup
from recipe_scrapers import SCRAPERS, get_host_name
from recipe_scrapers._factory import SchemaScraperFactory
from recipe_scrapers._schemaorg import SchemaOrg
@@ -15,7 +16,13 @@ SCRAPERS.update(CUSTOM_SCRAPERS)
def text_scraper(text, url=None):
scraper_class = SchemaScraperFactory.SchemaScraper
domain = None
if url:
domain = get_host_name(url)
if domain in SCRAPERS:
scraper_class = SCRAPERS[domain]
else:
scraper_class = SchemaScraperFactory.SchemaScraper
class TextScraper(scraper_class):
def __init__(