爬取这种类似的用python来的比较方便吧!
[Python] 纯文本查看 复制代码 import requests
from bs4 import BeautifulSoup
# 设置请求头部信息
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
# 请求页面内容
url = 'https://www.zhihu.com/topic/19552706/hot'
response = requests.get(url, headers=headers)
html_content = response.content
# 使用BeautifulSoup解析页面内容
soup = BeautifulSoup(html_content, 'html.parser')
question_items = soup.select('.HotList .HotItem')
# 遍历并输出每个问题的标题和链接
for item in question_items:
title_tag = item.select_one('.HotItem-title a')
title_text = title_tag.text.strip()
title_link = 'https://www.zhihu.com' + title_tag['href']
print(title_text, title_link)
|