Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix: resolve markdown links from the document URL
primorLee875385b56a3b
diff --git a/scrapegraphai/utils/convert_to_md.py b/scrapegraphai/utils/convert_to_md.pyindex bd7c994c..c6bf0bb5 100644--- a/scrapegraphai/utils/convert_to_md.py+++ b/scrapegraphai/utils/convert_to_md.py@@ -2,8 +2,6 @@convert_to_md module"""-from urllib.parse import urlparse-import html2text@@ -29,8 +27,6 @@ def convert_to_md(html: str, url: str = None) -> str:h.body_width = 0if url is not None:- parsed_url = urlparse(url)- domain = f"{parsed_url.scheme}://{parsed_url.netloc}"- h.baseurl = domain+ h.baseurl = urlreturn h.handle(html)diff --git a/tests/utils/convert_to_md_test.py b/tests/utils/convert_to_md_test.pyindex d2b64b48..1c02550f 100644--- a/tests/utils/convert_to_md_test.py+++ b/tests/utils/convert_to_md_test.py@@ -11,6 +11,15 @@ def test_html_with_links_and_images():assert convert_to_md(html) is not None+def test_relative_links_use_document_url_as_base():+ html = '<a href="guide.html">Guide</a><img src="images/logo.png" alt="Logo">'++ markdown = convert_to_md(html, "https://example.com/docs/index.html")++ assert "[Guide](https://example.com/docs/guide.html)" in markdown+ assert "" in markdown++def test_html_with_tables():html = """<table>