-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_reddot_block.py
More file actions
56 lines (46 loc) · 1.8 KB
/
remove_reddot_block.py
File metadata and controls
56 lines (46 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import re
file_path = r"c:\Users\assdr\Desktop\New Project\index.html"
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
# Helper to find matching closing div
def find_div_end(s, start_idx):
count = 1
i = start_idx + 1
while count > 0 and i < len(s):
if s[i:i+4] == '<div':
count += 1
i += 4
elif s[i:i+6] == '</div>':
count -= 1
i += 6
else:
i += 1
return i
# Find "Reddot"
target = "Reddot"
idx = content.find(target)
if idx != -1:
print(f"Found '{target}' at {idx}")
# Find start of container before this index
start_marker = '<div class="logo-parent-w">'
# rfind (reverse find) from 0 to idx
container_start = content.rfind(start_marker, 0, idx)
if container_start != -1:
print(f"Found container start at {container_start}")
container_end = find_div_end(content, container_start + len(start_marker))
print(f"Identified block from {container_start} to {container_end}")
print("Block content preview (start):", content[container_start:container_start+100])
print("Block content preview (end):", content[container_end-100:container_end])
# Verify it contains Reddot (sanity check)
if target in content[container_start:container_end]:
# Remove it
new_content = content[:container_start] + content[container_end:]
with open(file_path, "w", encoding="utf-8") as f:
f.write(new_content)
print("Successfully removed old logo block.")
else:
print("Error: Identified block does not contain target! Aborting.")
else:
print("Could not find container start before signal.")
else:
print(f"'{target}' not found.")