MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _extract_homepage_sections

Function _extract_homepage_sections

agents/coldstart-agent/main.py:1100–1149  ·  view source on GitHub ↗
(html_text: str)

Source from the content-addressed store, hash-verified

1098
1099
1100def _extract_homepage_sections(html_text: str) -> Dict[str, Any]:
1101 title = _strip_html(_extract_first_group(r"<title[^>]*>(.*?)</title>", html_text))
1102 description = _strip_html(
1103 _extract_first_group(
1104 r'<meta[^>]+name=["\']description["\'][^>]+content=["\'](.*?)["\']&#x27;,
1105 html_text,
1106 )
1107 )
1108 keywords_raw = _strip_html(
1109 _extract_first_group(
1110 r'<meta[^>]+name=["\']keywords["\'][^>]+content=["\'](.*?)["\']&#x27;,
1111 html_text,
1112 )
1113 )
1114 keywords = _dedupe_preserve_order(re.split(r"\s*,\s*", keywords_raw)) if keywords_raw else []
1115
1116 sections = {
1117 "research_interests": [],
1118 "research": [],
1119 "about": [],
1120 "projects": [],
1121 }
1122 lines = _html_to_text_lines(html_text)
1123 active_section = ""
1124 remaining_lines = 0
1125
1126 for line in lines:
1127 section_name = _classify_homepage_section(line)
1128 if section_name:
1129 active_section = section_name
1130 remaining_lines = 6 if section_name in {"research_interests", "research"} else 4
1131 inline_parts = re.split(r"[::]\s*", line, maxsplit=1)
1132 if len(inline_parts) == 2 and inline_parts[1].strip():
1133 sections[section_name].append(inline_parts[1].strip())
1134 remaining_lines -= 1
1135 continue
1136
1137 if active_section and remaining_lines > 0:
1138 sections[active_section].append(line)
1139 remaining_lines -= 1
1140 continue
1141
1142 active_section = ""
1143
1144 return {
1145 "title": title,
1146 "description": description,
1147 "keywords": keywords,
1148 "sections": {key: _dedupe_preserve_order(value) for key, value in sections.items()},
1149 }
1150
1151
1152def parse_research_homepage(homepage_url: str, use_llm: bool = True) -> Dict[str, Any]:

Callers 1

parse_research_homepageFunction · 0.85

Calls 5

_extract_first_groupFunction · 0.85
_dedupe_preserve_orderFunction · 0.85
_html_to_text_linesFunction · 0.85
_strip_htmlFunction · 0.70

Tested by

no test coverage detected