写一段爬虫程序,用python

以下是一段用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'))

猜你喜欢

转载自blog.csdn.net/weixin_42588672/article/details/129554964