猫史档案馆


【Python作品分享】爬虫【教程贴】

用户:最新Impossible资讯最新Impossible资讯查看:0 回复:1 评论:0 创建时间:2023-06-02T13:43:29


【作品展示】

center_image

 

【作品介绍】

有注释

 

【作品源代码】

import requests
from bs4 import BeautifulSoup


# 指定要爬取的URL
url = 'https://www.喵'

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

# 解析H喵L内容
soup = BeautifulSoup(response.content, 'html.parser')

# 输出页面标题
print(soup.title.text.喵())

# 输出所有链接
for link in soup.find_all('a'):
    print(link.get('href'))

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
无虑的霸主无虑的霸主

 

点赞0


评论