4 Commits

3 changed files with 1471 additions and 1414 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -101,7 +101,7 @@ def _image_results(doc: "ElementBase") -> EngineResults:
res.types.Image( res.types.Image(
url=extract_text(eval_xpath(result, "./@href")) or "", url=extract_text(eval_xpath(result, "./@href")) or "",
title=extract_text(eval_xpath(result, "./img/@alt")) or "", title=extract_text(eval_xpath(result, "./img/@alt")) or "",
thumbnail_src=extract_text(eval_xpath(result, "./img/@src")) or "", img_src=extract_text(eval_xpath(result, "./img/@src")) or "",
), ),
) )
) )

View File

@@ -73,7 +73,7 @@ def _obtain_session_code() -> str:
if cached_session: if cached_session:
return cached_session return cached_session
results_page = get(f"{base_url}/_internCode.aspx") results_page = get(f"{base_url}/checkCode.aspx")
doc = html.fromstring(results_page.text) doc = html.fromstring(results_page.text)
extra_data: dict[str, str] = {} extra_data: dict[str, str] = {}
@@ -107,7 +107,7 @@ def _obtain_session_code() -> str:
} }
challenge_response = post( challenge_response = post(
f"{base_url}/_internCode.aspx", f"{base_url}/checkCode.aspx",
cookies=results_page.cookies, cookies=results_page.cookies,
data=data, data=data,
) )
@@ -125,7 +125,9 @@ def request(query: str, params: "OnlineParams"):
code = _obtain_session_code() code = _obtain_session_code()
args = {"w": query, "page": params["pageno"]} args = {"w": query, "page": params["pageno"]}
params["url"] = f"{base_url}/{tiger_category}?{urlencode(args)}" params["url"] = f"{base_url}/{tiger_category}?{urlencode(args)}"
params["cookies"]["Tiger.ch"] = f"Code={code}" # Setting Checked=1 shows related search terms / suggestions
# Language and country could be set with Lng= and Land= in the future
params["cookies"]["Tiger.ch"] = f"Tiger.ch=&Code={code}&Checked=1"
def response(resp: "SXNG_Response") -> EngineResults: def response(resp: "SXNG_Response") -> EngineResults:
@@ -144,6 +146,9 @@ def response(resp: "SXNG_Response") -> EngineResults:
content=extract_text(eval_xpath(result, ".//*[contains(@class, 'webbodynopic')]")) or "", content=extract_text(eval_xpath(result, ".//*[contains(@class, 'webbodynopic')]")) or "",
) )
) )
for suggestion in eval_xpath_list(doc, "//a[contains(@class, 'linkAnders')]"):
res.add(res.types.LegacyResult(suggestion=extract_text(suggestion)))
elif tiger_category == "News": elif tiger_category == "News":
for result in eval_xpath_list(doc, "//div[@id='panNews']/div"): for result in eval_xpath_list(doc, "//div[@id='panNews']/div"):
publishedDate = None publishedDate = None