Skip to content

Commit

Permalink
issue scrapy#49
Browse files Browse the repository at this point in the history
  • Loading branch information
marekyggdrasil committed Nov 27, 2019
1 parent 3fda642 commit f7eb748
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scrapely/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def best_match(text):
def func(fragment, page):
fdata = page.fragment_data(fragment).strip()
if text in fdata:
if not len(fdata):
return float("inf")
return float(len(text)) / len(fdata) - (1e-6 * fragment.start)
else:
return 0.0
Expand Down

0 comments on commit f7eb748

Please sign in to comment.