• 学习使用Python的requestsBeautifulSoup库爬取网页数据。
  • 理解HTTP请求和HTML解析。
 
import requests
from bs4 import BeautifulSoup

def fetch_hot_words(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    hot_words = [tag.text for tag in soup.find_all('a', class_='hot-word')]
    return hot_words

url = "https://example.com/hot-words"
print(fetch_hot_words(url))