Fix explicit anchor text to randomize term selection
Randomize anchor text list before trying terms so all explicit terms are used across articles instead of always using the first term.main
parent
de21a22b72
commit
56d7e4f642
|
|
@ -336,6 +336,10 @@ def _try_inject_link(html: str, anchor_texts: List[str], target_url: str) -> Tup
|
|||
Try to inject a link with anchor text into HTML
|
||||
Returns (updated_html, link_injected, anchor_text_used)
|
||||
"""
|
||||
# Randomize order to use different terms across articles
|
||||
if anchor_texts and len(anchor_texts) > 1:
|
||||
anchor_texts = random.sample(anchor_texts, len(anchor_texts))
|
||||
|
||||
for anchor_text in anchor_texts:
|
||||
# Try to find and wrap anchor text in content
|
||||
updated_html, found = _find_and_wrap_anchor_text(html, anchor_text, target_url)
|
||||
|
|
|
|||
Loading…
Reference in New Issue