webpages-validator-ssc 0.2.1__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.
@@ -0,0 +1,9 @@
1
+ # MIT License
2
+
3
+ Copyright © 2025 Ildar Gaziev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.2
2
+ Name: webpages-validator-ssc
3
+ Version: 0.2.1
4
+ Summary: A simple command-line utility for checking a webpage.
5
+ Author-email: Ildar Gaziev <ildar@gaziev.info>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ildar-gaziev/simple-site-checker
8
+ Project-URL: repository, https://github.com/ildar-gaziev/simple-site-checker
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.md
12
+
13
+ # Simple Site Checker
14
+
15
+ ## (webpages-validator-ssc)
16
+
17
+ Simple command-line utility for checking links on a web page.
18
+
19
+ ---
20
+
21
+ ## Overview
22
+
23
+ `simple-site-checker` (`ssc`) is a lightweight Python CLI tool designed to quickly verify the HTTP status codes of all hyperlinks on a given web page. It uses only standard Python libraries and has no external dependencies.
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ### Install via PIP
30
+
31
+ ```bash
32
+ pip install webpages-validator-ssc
33
+ ```
34
+
35
+ ```bash
36
+ ssc -links -url https://www.example.com
37
+ ```
38
+
39
+ ### Optional: Save results to CSV
40
+
41
+ ```bash
42
+ ssc -links -url https://www.example.com -res results.csv
43
+ ```
44
+
45
+ ### Optional: set cookies
46
+
47
+ ```bash
48
+ ssc -links -url https://www.example.com -auth cookies.txt
49
+ ```
50
+
51
+ #### cookies.txt
52
+
53
+ ```txt
54
+ name=value
55
+ ```
@@ -0,0 +1,43 @@
1
+ # Simple Site Checker
2
+
3
+ ## (webpages-validator-ssc)
4
+
5
+ Simple command-line utility for checking links on a web page.
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ `simple-site-checker` (`ssc`) is a lightweight Python CLI tool designed to quickly verify the HTTP status codes of all hyperlinks on a given web page. It uses only standard Python libraries and has no external dependencies.
12
+
13
+ ---
14
+
15
+ ## Installation
16
+
17
+ ### Install via PIP
18
+
19
+ ```bash
20
+ pip install webpages-validator-ssc
21
+ ```
22
+
23
+ ```bash
24
+ ssc -links -url https://www.example.com
25
+ ```
26
+
27
+ ### Optional: Save results to CSV
28
+
29
+ ```bash
30
+ ssc -links -url https://www.example.com -res results.csv
31
+ ```
32
+
33
+ ### Optional: set cookies
34
+
35
+ ```bash
36
+ ssc -links -url https://www.example.com -auth cookies.txt
37
+ ```
38
+
39
+ #### cookies.txt
40
+
41
+ ```txt
42
+ name=value
43
+ ```
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "webpages-validator-ssc"
7
+ version = "0.2.1"
8
+ description = "A simple command-line utility for checking a webpage."
9
+ authors = [{ name = "Ildar Gaziev", email = "ildar@gaziev.info" }]
10
+ readme = "README.md"
11
+ requires-python = ">=3.6"
12
+ license = { text = "MIT" }
13
+
14
+ [project.urls]
15
+ Homepage = "https://github.com/ildar-gaziev/simple-site-checker"
16
+ repository = "https://github.com/ildar-gaziev/simple-site-checker"
17
+
18
+ [project.scripts]
19
+ ssc = "ssc.cli:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1 @@
1
+ from .auth import load_cookies
@@ -0,0 +1,4 @@
1
+ def load_cookies(cookie_file):
2
+ with open(cookie_file, 'r', encoding='utf-8') as f:
3
+ cookie_data = f.read().strip()
4
+ return cookie_data
@@ -0,0 +1,26 @@
1
+ import argparse
2
+ from .links import validate_links
3
+ from .links.saver import save_to_csv
4
+
5
+
6
+ def main():
7
+ parser = argparse.ArgumentParser(description='Simple Site Checker')
8
+ parser.add_argument('-links', action='store_true',
9
+ help='Check all links on the page')
10
+ parser.add_argument('-url', required=True,
11
+ help='URL of the webpage to check')
12
+ parser.add_argument('-auth', help='Path to cookie file for authentication')
13
+ parser.add_argument('-res', help='Save results to CSV file')
14
+
15
+ args = parser.parse_args()
16
+
17
+ if args.links:
18
+ results = validate_links(args.url, cookie_file=args.auth)
19
+
20
+ if args.res:
21
+ save_to_csv(results, args.res)
22
+ print(f'Results saved to {args.res}')
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
@@ -0,0 +1 @@
1
+ from .checker import validate_links
@@ -0,0 +1,61 @@
1
+ import urllib.request
2
+ from urllib.parse import urljoin
3
+ from html.parser import HTMLParser
4
+ from ..auth import load_cookies
5
+
6
+
7
+ class LinkParser(HTMLParser):
8
+ def __init__(self, base_url):
9
+ super().__init__()
10
+ self.links = []
11
+ self.base_url = base_url
12
+
13
+ def handle_starttag(self, tag, attrs):
14
+ if tag == 'a':
15
+ for attr, value in attrs:
16
+ if attr == 'href' and not value.startswith('mailto:'):
17
+ url = urljoin(self.base_url, value)
18
+ self.links.append(url)
19
+
20
+
21
+ def check_url(url, headers=None):
22
+ req = urllib.request.Request(url, headers=headers or {})
23
+ try:
24
+ with urllib.request.urlopen(req, timeout=5) as response:
25
+ return response.getcode()
26
+ except Exception as e:
27
+ print(f'Error checking {url}: {e}')
28
+ return None
29
+
30
+
31
+ def validate_links(page_url, cookie_file=None):
32
+ results = []
33
+
34
+ headers = {}
35
+ if cookie_file:
36
+ cookie_data = load_cookies(cookie_file)
37
+ headers = {'Cookie': cookie_data}
38
+ else:
39
+ headers = {}
40
+
41
+ try:
42
+ req = urllib.request.Request(page_url, headers=headers or {})
43
+ with urllib.request.urlopen(req) as response:
44
+ html_content = response.read().decode()
45
+ except Exception as e:
46
+ print(f'Error loading page {page_url}: {e}')
47
+ return results
48
+
49
+ parser = LinkParser(page_url)
50
+ parser.feed(html_content)
51
+
52
+ valid_codes = range(200, 400)
53
+ for link in set(parser.links):
54
+ code = check_url(link, headers=headers)
55
+ if code in valid_codes:
56
+ print(f'OK ({code}): {link}')
57
+ elif code:
58
+ print(f'BAD ({code}): {link}')
59
+ results.append((link, code))
60
+
61
+ return results
@@ -0,0 +1,8 @@
1
+ import csv
2
+
3
+
4
+ def save_to_csv(results, filename):
5
+ with open(filename, mode='w', newline='', encoding='utf-8') as csvfile:
6
+ writer = csv.writer(csvfile)
7
+ writer.writerow(['link', 'code'])
8
+ writer.writerows(results)
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.2
2
+ Name: webpages-validator-ssc
3
+ Version: 0.2.1
4
+ Summary: A simple command-line utility for checking a webpage.
5
+ Author-email: Ildar Gaziev <ildar@gaziev.info>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ildar-gaziev/simple-site-checker
8
+ Project-URL: repository, https://github.com/ildar-gaziev/simple-site-checker
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.md
12
+
13
+ # Simple Site Checker
14
+
15
+ ## (webpages-validator-ssc)
16
+
17
+ Simple command-line utility for checking links on a web page.
18
+
19
+ ---
20
+
21
+ ## Overview
22
+
23
+ `simple-site-checker` (`ssc`) is a lightweight Python CLI tool designed to quickly verify the HTTP status codes of all hyperlinks on a given web page. It uses only standard Python libraries and has no external dependencies.
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ### Install via PIP
30
+
31
+ ```bash
32
+ pip install webpages-validator-ssc
33
+ ```
34
+
35
+ ```bash
36
+ ssc -links -url https://www.example.com
37
+ ```
38
+
39
+ ### Optional: Save results to CSV
40
+
41
+ ```bash
42
+ ssc -links -url https://www.example.com -res results.csv
43
+ ```
44
+
45
+ ### Optional: set cookies
46
+
47
+ ```bash
48
+ ssc -links -url https://www.example.com -auth cookies.txt
49
+ ```
50
+
51
+ #### cookies.txt
52
+
53
+ ```txt
54
+ name=value
55
+ ```
@@ -0,0 +1,15 @@
1
+ LICENSE.md
2
+ README.md
3
+ pyproject.toml
4
+ ssc/__init__.py
5
+ ssc/cli.py
6
+ ssc/auth/__init__.py
7
+ ssc/auth/auth.py
8
+ ssc/links/__init__.py
9
+ ssc/links/checker.py
10
+ ssc/links/saver.py
11
+ webpages_validator_ssc.egg-info/PKG-INFO
12
+ webpages_validator_ssc.egg-info/SOURCES.txt
13
+ webpages_validator_ssc.egg-info/dependency_links.txt
14
+ webpages_validator_ssc.egg-info/entry_points.txt
15
+ webpages_validator_ssc.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ssc = ssc.cli:main