以下是一个简单的Python爬虫示例,用于从指定的网页中提取标题和链接:

import requests
from bs4 import BeautifulSoup

def crawl(url):
    # 发送HTTP GET请求获取网页内容
    response = requests.get(url)
    
    # 使用BeautifulSoup解析网页内容
    soup = BeautifulSoup(response.text, 'html.parser')
    
    # 提取所有的<a>标签
    links = soup.find_all('a')
    
    # 打印标题和链接
    for link in links:
        print(link.text.strip())
        print(link['href'])
        print('---')

# 调用爬虫函数
crawl('https://www.example.com')

这个爬虫使用了第三方库requests来发送HTTP请求,使用BeautifulSoup来解析网页内容。它会从指定的URL中提取所有的<a>标签,并打印出标题和链接。你可以将'https://www.example.com'替换为你想要爬取的网页URL。