我正在学习/正在进行网络抓取并停留在问题上,我有一个bs4.element.ResultSet
类型的对象
其中包含一些div标签,我想像在bs4.BeautifulSoup
类型对象中一样提取它
我想要突出显示的代码
所以我做了
from bs4 import BeautifulSoup
import requests
url = 'https://www.simplilearn.com/resources'
result = requests.get(url)
web_page = result.content
soup = BeautifulSoup(web_page, 'html.parser')
article = soup.findAll(class_='contentBySegment') #that gives me bs4.element.ResultSet
然后,我尝试使用find方法,但是它不起作用,反而出现错误。
我的目标是获取文章主题名称
可以在该代码的这一部分中看到
所以,我该怎么办
答案 0 :(得分:0)
from bs4 import BeautifulSoup
import requests
r = requests.get("https://www.simplilearn.com/resources")
soup = BeautifulSoup(r.text, 'html.parser')
for item in soup.findAll("h4", {'class': 'content-title'}):
print(item.text)
输出:
How to Become a Certified ScrumMaster
Top 20 Agile Scrum Master Interview Questions & Answers
Free eBook: Guide To Scrum Methodology
The Importance of Machine Learning for Data Scientists
Introduction to Data Science: A Tutorial for Beginners
The Roadmap to a Successful Data Science Career With the PG Program From Simplilearn
Google Discontinued RHS Ads: How Does This Affects Online Marketers?
Penguin 4.0 Update: The Best Advice From Experts You're Not Taking
Digital Marketing Career Guide: A Playbook to Becoming a Digital Marketing Specialist
Cyber Security Tutorial: The A to Z to get started
What is Computer Security?
Cybersecurity Career Guide: A Comprehensive Playbook to Becoming A Cybersecurity Expert
12 Reasons to Get a TOGAF Certification
ITIL: Key Concepts and Summary
Free eBook: Enterprise Architecture Salary Report
Project Management Learning Series: Fast Tracking Versus Crashing
Top 10 Reasons to Get a PRINCE2 Certification
Free Mind-map: PMP Certification
Prepare for Important Salesforce Interview Questions and Answers
Salesforce Developer Certification: an overview
Free eBook: Salesforce Developer Salary Report
Top IT Certification Courses For a Rewarding Career
AWS Careers: A Good Move for Cloud Computing Enthusiasts
AWS Career Guide: A Comprehensive Playbook To Becoming an AWS Solution Architect
Reskilling the Government Workforce for the Digital Age
How important is the Abraham Maslow’s motivation theory in developing the project team
Report: The Future of IT Jobs in India
Upskilling for the Fourth Industrial Revolution
Selling Your Idea to Leadership
IDC Study: How Blended Learning Impacts Training Success
The Top 5 Myths of Digital Transformation
Course Announcement: Simplilearn’s Introduction to Digital Transformation
Skilling 4.0: A Study on Digital Readiness
4 Great Ways to Usher in National Technology Day
Go Programming Language: An Introduction
40+ Resources to Help You Learn Java Online