如何用Python写爬虫
引言爬虫是数据采集的重要工具。本文将带你用Python快速上手爬虫开发。 正文环境准备1pip install requests beautifulsoup4 发送HTTP请求123456import requestsurl = "https://example.com"response = requests.get(url)print(response.status_code)print(response.text[:500]) 解析HTML123456from bs4 import BeautifulSoupsoup = BeautifulSoup(response.text, 'html.parser')titles = soup.find_all('h1')for title in titles: print(title.get_text()) 保存数据12345678import jsondata = { 'title': '示例标题', ...
我的第一篇技术笔记
这是一篇技术笔记的示例文章。 代码示例12345def hello_world(): print("Hello, World!") return "success"hello_world() 后续计划后续我会在这里分享更多技术文章,包括但不限于: Python 编程技巧 前端开发经验 机器学习项目实践 算法题解