softhauzpy 0.0.7__tar.gz → 0.0.81__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: softhauzpy
3
- Version: 0.0.7
3
+ Version: 0.0.81
4
+ Summary: is a comprehensive Python toolkit built for developers creating intelligent, data-driven web applications. It provides a powerful suite of web utilities including web scraping tools, crawling systems, content extraction pipelines, and search engine components that help developers build fully customizable in-house website search solutions.
5
+ Home-page: https://softhauz.ca
4
6
  Author: Karen Urate
5
7
  Author-email: karen.urate@softhauz.ca
8
+ License: MIT
6
9
  Description-Content-Type: text/markdown
7
10
 
8
11
  # SofthauzPy
@@ -0,0 +1,22 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding="utf-8") as f:
4
+ long_description = f.read()
5
+
6
+ setup(
7
+ name='softhauzpy',
8
+ version='0.0.81',
9
+ author='Karen Urate',
10
+ author_email='karen.urate@softhauz.ca',
11
+ packages=find_packages(),
12
+ install_requires=[
13
+ 'requests>=2.32.3',
14
+ 'beautifulsoup4>=4.12.3',
15
+ 'nltk>=3.9.4'
16
+ ],
17
+ url="https://softhauz.ca",
18
+ license="MIT",
19
+ description="is a comprehensive Python toolkit built for developers creating intelligent, data-driven web applications. It provides a powerful suite of web utilities including web scraping tools, crawling systems, content extraction pipelines, and search engine components that help developers build fully customizable in-house website search solutions.",
20
+ long_description=long_description,
21
+ long_description_content_type="text/markdown",
22
+ )
@@ -3,7 +3,7 @@ from .main import incremental_update, highlight_query_terms, build_sitemap_urls
3
3
  from .main import fingerprint_page, generate_snippet
4
4
 
5
5
  # extractions
6
- from .main import extract_structured_data, extract_headings
6
+ from .main import detect_input_type, extract_structured_data, extract_headings
7
7
  from .main import extract_metadata, extract_links, extract_pure_text
8
8
 
9
9
  # indexing
@@ -15,7 +15,7 @@ External Package List:
15
15
  - nltk >= (v. 3.9.4)
16
16
 
17
17
  """
18
-
18
+ import os
19
19
  import re
20
20
  import json
21
21
  import math
@@ -56,6 +56,38 @@ except Exception:
56
56
  }
57
57
  _NLTK_AVAILABLE = False
58
58
 
59
+ """
60
+ Detect whether the input is a URL, an HTML file path, or a raw string.
61
+
62
+ Parameters
63
+ ----------
64
+ value : String - The input to evaluate.
65
+
66
+ Returns
67
+ -------
68
+ url : String - 'url', 'html_file', or 'raw_string'
69
+ """
70
+ def detect_input_type(value: str) -> str:
71
+ # Check if it's a URL (http/https/ftp scheme)
72
+ try:
73
+ parsed = urlparse(value)
74
+ if parsed.scheme in ("http", "https", "ftp", "ftps"):
75
+ return "url"
76
+ except Exception:
77
+ pass
78
+
79
+ # Check if it's a path to an existing HTML file
80
+ if os.path.isfile(value) and value.lower().endswith((".html", ".htm")):
81
+ return "html_file"
82
+
83
+ # Check if it looks like an HTML string even if not a file
84
+ stripped = value.strip()
85
+ if stripped.startswith("<") and stripped.endswith(">"):
86
+ return "raw_string"
87
+
88
+ # Default: treat as plain raw string
89
+ return "raw_string"
90
+
59
91
  """
60
92
 
61
93
  Fetch a webpage and return only the pure text content found within its HTML tags.
@@ -88,8 +120,6 @@ except Exception:
88
120
  If the server returns a non-2xx status code.
89
121
 
90
122
  """
91
-
92
-
93
123
  def extract_pure_text(
94
124
  page_url: str,
95
125
  *,
@@ -98,10 +128,22 @@ def extract_pure_text(
98
128
  description: str | None = None,
99
129
  creation_date: str | None = None,
100
130
  modified_date: str | None = None) -> dict:
101
- response = fetch_page(page_url, timeout=15)
102
- response.raise_for_status()
103
131
 
104
- soup = BeautifulSoup(response.text, "html.parser")
132
+ input_type = detect_input_type(page_url)
133
+
134
+ if input_type == "url":
135
+ response = fetch_page(page_url, timeout=15)
136
+ response.raise_for_status()
137
+ html_content = response.text
138
+
139
+ elif input_type == "html_file":
140
+ with open(page_url, "r", encoding="utf-8") as f:
141
+ html_content = f.read()
142
+
143
+ else:
144
+ html_content = page_url
145
+
146
+ soup = BeautifulSoup(html_content, "html.parser")
105
147
 
106
148
  for tag in soup.find_all(_SKIP_TAGS):
107
149
  tag.decompose()
@@ -1,8 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: softhauzpy
3
- Version: 0.0.7
3
+ Version: 0.0.81
4
+ Summary: is a comprehensive Python toolkit built for developers creating intelligent, data-driven web applications. It provides a powerful suite of web utilities including web scraping tools, crawling systems, content extraction pipelines, and search engine components that help developers build fully customizable in-house website search solutions.
5
+ Home-page: https://softhauz.ca
4
6
  Author: Karen Urate
5
7
  Author-email: karen.urate@softhauz.ca
8
+ License: MIT
6
9
  Description-Content-Type: text/markdown
7
10
 
8
11
  # SofthauzPy
softhauzpy-0.0.7/setup.py DELETED
@@ -1,19 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- with open("README.md", "r", encoding="utf-8") as f:
4
- description = f.read()
5
-
6
- setup(
7
- name='softhauzpy',
8
- version='0.0.7',
9
- author='Karen Urate',
10
- author_email='karen.urate@softhauz.ca',
11
- packages=find_packages(),
12
- install_requires=[
13
- 'requests>=2.32.3',
14
- 'beautifulsoup4>=4.12.3',
15
- 'nltk>=3.9.4'
16
- ],
17
- long_description=description,
18
- long_description_content_type="text/markdown",
19
- )
File without changes
File without changes