简体   繁体   English

美丽的汤找不到Div

[英]Beautiful Soup not finding Div

I'm trying to get products for a project i'm working on from this page: Belk.com 我正试图从此页面上获取我正在从事的项目的产品: Belk.com

I originally tried going very specific using 我最初尝试使用非常具体的方法

soup.find("ul", {"class" : "product_results"})

Nothing was happening, so I went very broad and just started searching all divs. 什么也没发生,所以我走得很远,才开始搜索所有div。

contentDiv = soup.find_all("div")
for div in contentDiv:
    print(div.get("class"))

When I do this I am getting only Div's for the top half of the page, which lead me to believe that there is an iframe that I wasn't getting into, but upon closer inspection I couldn't find the frame. 执行此操作时,页面的上半部分仅显示Div,这使我相信我没有进入iframe,但仔细检查后找不到该iframe。 Any thoughts on this? 有什么想法吗?

This works for me 这对我有用

import httplib2
from bs4 import BeautifulSoup

http = httplib2.Http()
status, response = http.request('http://www.belk.com/AST/Main/Belk_Primary/Women/Shop/Accessories.jsp')

soup = BeautifulSoup(response)

res = soup.find('ul',{"class":"product_results"})
lis = res.findAll('li')
for j in lis:
    #your code
    pass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM