Adds `_fetch_page_content()`, which downloads a URL with a browser-like User-Agent and uses BeautifulSoup with the lxml parser to strip scripts, navigation, and other non-content markup, returning up to 3000 characters of readable text. The response validator now also compares generated replies against this scraped text, flagging named entities and claims that do not appear in the retrieved page content. Dependencies: adds beautifulsoup4==4.12.3 and pins lxml==5.3.0 for parser compatibility.
23 lines
574 B
Python
23 lines
574 B
Python
# this is a package
|
|
|
|
__version__ = "5.3.0"
|
|
|
|
|
|
def get_include():
|
|
"""
|
|
Returns a list of header include paths (for lxml itself, libxml2
|
|
and libxslt) needed to compile C code against lxml if it was built
|
|
with statically linked libraries.
|
|
"""
|
|
import os
|
|
lxml_path = __path__[0]
|
|
include_path = os.path.join(lxml_path, 'includes')
|
|
includes = [include_path, lxml_path]
|
|
|
|
for name in os.listdir(include_path):
|
|
path = os.path.join(include_path, name)
|
|
if os.path.isdir(path):
|
|
includes.append(path)
|
|
|
|
return includes
|