def fas_get_company_profile_url(response: Response, name: str) -> str:
content = response.content.decode("utf-8")
links_to_profiles_selector = "#ed-search-list-container a"
href_selector = "a::attr(href)"
links_to_profiles = Selector(text=content).css(
links_to_profiles_selector).extract()
profile_url = None
for link in links_to_profiles:
if escape_html(name).lower() in escape_html(link).lower():
profile_url = Selector(text=link).css(href_selector).extract()[0]
with assertion_msg(
"Couldn't find link to '%s' company profile page in the response",
name):
assert profile_url
return profile_url
评论列表
文章目录