以下是一个简单的Python爬虫脚本示例:

import requests
from bs4 import BeautifulSoup

# 定义要爬取的URL
url = "https://example.com"

# 发起HTTP请求
response = requests.get(url)

# 解析HTML内容
soup = BeautifulSoup(response.text, "html.parser")

# 提取所需的信息
title = soup.title.string

# 打印结果
print("网页标题: " + title)

这个脚本使用了requests库来发起HTTP请求,使用了BeautifulSoup库来解析HTML内容。在示例中,我们爬取了一个网页的标题并打印出来。

请注意,在使用爬虫脚本时需要遵守网站的爬虫规则,并尊重网站的使用条款和隐私政策。

python爬虫脚本

原文地址: https://www.cveoy.top/t/topic/hPn9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录