【发布时间】:2020-07-19 05:49:34
【问题描述】:
我正在使用python的beautifulSoup包来抓取以下页面:https://www.nike.com/w/womens-shoes-5e1x6zy7ok
当我使用以下代码时:
data = br.open("https://www.nike.com/w/womens-shoes-5e1x6zy7ok").read()
soup = BS(data)
shoes = soup.find_all('div', {'class':'product-card__body'})
我只收到:
<picture><source media="0" srcset=""/><source media="1" srcset=""/><source media="2" srcset=""/><img alt="Nike Air Max 2090 Women's Shoe" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/></picture>
但是,如果我直接从网站的 URL 复制,我会收到更多信息:
<picture><source srcset="product-card__body" media="(min-width: 1024px)"><source srcset="https://static.nike.com/a/images/c_limit,w_592,f_auto/t_product_v1/b2bfaf14-ed59-48a7-b8ae-e684b1d605ce/air-max-270-react-se-womens-shoe-6bhhrf.jpg" media="(max-width: 1023px) and (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)"><source srcset="https://static.nike.com/a/images/c_limit,w_318,f_auto/t_product_v1/b2bfaf14-ed59-48a7-b8ae-e684b1d605ce/air-max-270-react-se-womens-shoe-6bhhrf.jpg" media="(max-width: 1023px)"><img src="https://static.nike.com/a/images/c_limit,w_318,f_auto/t_product_v1/b2bfaf14-ed59-48a7-b8ae-e684b1d605ce/air-max-270-react-se-womens-shoe-6bhhrf.jpg" alt="Nike Air Max 270 React SE Women's Shoe"></picture>
如何使用beautifulsoup获取后面的信息?
【问题讨论】:
-
您想获取什么信息?页面上所有图像的标题?只是第一个标题?
-
真正与每只鞋子相关的所有信息,包括鞋子的图片@Mendelg
-
你用的是什么
br.open?那些picture元素是什么?我已经尝试过 requests + bs4 并且我从链接中得到了我应该得到的东西
标签: python html python-3.x web-scraping beautifulsoup