首页 > 编程知识 正文

python和爬虫什么关系,python爬虫基础教程

时间:2023-05-05 21:00:01 阅读:174661 作者:2703

使用request获取web资源导入# importrequestsfrombs4importbeautifulsoup # RES=requests.get (' https://www.Sina.com.cn 使用beautifulsoup获取指定的资源,将#转换请求与soup对应,html解释器soup=beautiful soup (' html.parser ' ) #获取指定的id内容- - ad_45976 ) ) --:打印) news.text ) )获取指定的html标签内容并直接使用。获取33660打印(news.text )指定的类的内容--:是. )中获取所需的class的内容)组合以获取子级print (.text ) class top-nav下的class tn-title的内容#组合查询属性print (soup.select (' a [ a ] )

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。