使用美丽的汤在Div中获取物品列表
我正在尝试使用美丽的汤来从a
from bs4 import BeautifulSoup
page = requests.get("https://www.udacity.com/courses/all?price=Free",verify=False)
soup = BeautifulSoup(page.content, 'html.parser')
ls=soup.find_all('ul', {'class': 'catalog-v2_results__1FjDi'})
print(ls)
I am trying to use beautiful soup to pull a list of courses from a website but have little success. I have attached the HTML structure of the website below. I am trying to pull the list of elements from <ul class="catalog-v2_results__1FjDi"> class. The below code returns nothing. I have very little familiarity with HTML and trying to find the easiest way of doing this.
from bs4 import BeautifulSoup
page = requests.get("https://www.udacity.com/courses/all?price=Free",verify=False)
soup = BeautifulSoup(page.content, 'html.parser')
ls=soup.find_all('ul', {'class': 'catalog-v2_results__1FjDi'})
print(ls)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该网页是动态的,BS4不能呈现JavaScript,但是可以使用硒的BS4模仿。我使用CSS选择器来解析HTML DOM元素。
示例:
输出:
The webpage is dynamic and bs4 can't render JavaScript but can mimic using bs4 with selenium. I use CSS selectors to parse the html DOM elements.
Example:
Output: