webcode-tk 1.2.9__tar.gz → 1.2.11__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webcode-tk
3
- Version: 1.2.9
3
+ Version: 1.2.11
4
4
  Summary: A set of tools for inspecting HTML and CSS code
5
5
  License: MIT
6
6
  License-File: LICENSE.rst
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "webcode-tk"
3
- version = "1.2.9"
3
+ version = "1.2.11"
4
4
  description = "A set of tools for inspecting HTML and CSS code"
5
5
  authors = ["hundredvisionsguy <cwinikka@gmail.com>"]
6
6
  keywords = ["html", "validation", "css", ]
@@ -40,4 +40,4 @@
40
40
  - **`validator_tools`**: sends HTML or CSS code to the W3C Validator to check
41
41
  for errors.
42
42
  """
43
- __version__ = "1.2.9"
43
+ __version__ = "1.2.11"
@@ -50,6 +50,29 @@ def get_all_html_files(dir_path: str) -> list:
50
50
  return html_files
51
51
 
52
52
 
53
+ def get_image_hotlinks(soup: BeautifulSoup) -> list:
54
+ """Returns a list of all img src values that are external (hotlinked) URLs.
55
+
56
+ Hotlinked images are those with src attributes pointing to external
57
+ domains rather than local/relative paths. I ask that all students avoid
58
+ hotlinking images, as it's bad form and generally frowned upon.
59
+
60
+ Args:
61
+ soup: html soupt object.
62
+
63
+ Returns:
64
+ hotlinks: a list of hotlinked image srcs"""
65
+ hotlinks = []
66
+ # Get all img urls
67
+ image_elements = soup.find_all("img")
68
+ image_srcs = [img["src"] for img in image_elements]
69
+ for src in image_srcs:
70
+ if "http" in src[:4]:
71
+ hotlinks.append(src)
72
+
73
+ return hotlinks
74
+
75
+
53
76
  def get_html(file_path: str) -> BeautifulSoup:
54
77
  """Returns an html document (from file_path) as a BeautifulSoup object
55
78
 
File without changes
File without changes