以下是一段用Python编写的爬虫程序:
import requests from bs4 import BeautifulSoup
url = 'http://example.com/'
发出请求
response = requests.get(url)
解析网页
soup = BeautifulSoup(response.text, 'html.parser')
找出所有的链接
links = soup.find_all('a')
遍历链接
for link in links: print(link.get('href'))