[百度百科简介内容解析] #爬虫
✓ Published0🌍 Public
SShawn91
Last edited Jan 25, 2019
Created on Jan 15, 2019
This example parses the summary table from Baidu Baike encyclopedia pages to extract short names, abbreviations, and foreign-company division names. It uses the BeautifulSoup library to locate the HTML element with class `basic-info cmn-clearfix`, then a helper function `get_baike_shorten_names` finds a definition term (like `dt` for “英文名”) and retrieves its sibling `dd` value, cleaning out bracketed reference numbers with a regular expression. The code demonstrates a reusable scraping pattern for structured infobox data from Baidu Baike, returning the cleaned text or an empty string when no match is found.
AI-generated description