• 学习使用搜索引擎API(如百度搜索)查找热词引用。
  • 理解如何从搜索结果中提取链接。
 
def search_word_references(word):
    url = f"https://www.baidu.com/s?wd={word}"
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    links = [a['href'] for a in soup.find_all('a', href=True)]
    return links

print(search_word_references("人工智能"))