updated lite

This commit is contained in:
Concedo 2024-12-29 17:04:29 +08:00
parent 2de1975ca2
commit 5451a8e8a9
2 changed files with 139 additions and 35 deletions

File diff suppressed because one or more lines are too long

View file

@ -1378,11 +1378,11 @@ def websearch(query):
if matches.size > 100 and desclen-matches.size < 50: #good enough match if matches.size > 100 and desclen-matches.size < 50: #good enough match
# expand description by some chars both sides # expand description by some chars both sides
expandamtbefore = 250 expandamtbefore = 250
expandamtafter = 600 expandamtafter = 750
startpt = matches.a - expandamtbefore startpt = matches.a - expandamtbefore
startpt = 0 if startpt < 0 else startpt startpt = 0 if startpt < 0 else startpt
endpt = matches.a + expandamtafter + desclen endpt = matches.a + expandamtafter + desclen
pagedesc = scraped[startpt:endpt] pagedesc = scraped[startpt:endpt].strip()
except Exception: except Exception:
pass pass
searchresults.append({"title":title,"url":url,"desc":desc,"content":pagedesc}) searchresults.append({"title":title,"url":url,"desc":desc,"content":pagedesc})