亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Requests_HTML 抓取 JS 渲染頁面未按預期工作

使用 Requests_HTML 抓取 JS 渲染頁面未按預期工作

紅顏莎娜 2023-06-13 17:12:56
我正在研究 Scraping JS 渲染頁面 ( https://www.flipkart.com/search?q=Acer+Laptops )。在此頁面中,產品圖像是動態加載的。這些圖像的預渲染 SRC 值是//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/placeholder_9951d0.svg渲染后,SRC應該是這樣的https://rukminim1.flixcart.com/image/312/312/kcp4osw0/computer/f/w/d/acer-na-thin-and-light-laptop-original-imaftrdmuyxq5nrf.jpeg?q=70使用 requests_html 我可以獲得 SRC 值,但它僅適用于頂部的前幾張圖像。請幫幫我好嗎?我的代碼:-res = session.get("https://www.flipkart.com/search?q=Acer+Laptops")res.html.render()all_results = res.html.find('#container > div > div.t-0M7P._2doH3V > div._3e7xtJ > div._1HmYoV.hCUpcT > div:nth-child(2)', first=True) #Container for all the resultsitems = all_results.find('._1UoZlX') # Container for each product being displayedfor item in items:   item_image = item.find('div._3BTv9X img', first=True).attrs.get('src')   print(item_image)輸出:-https://rukminim1.flixcart.com/image/312/312/kamtsi80/computer/m/8/y/acer-na-gaming-laptop-original-imafs5prytwgrcyf.jpeg?q=70https://rukminim1.flixcart.com/image/312/312/kcp4osw0/computer/f/w/d/acer-na-thin-and-light-laptop-original-imaftrdmuyxq5nrf.jpeg?q=70//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/placeholder_9951d0.svg//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/placeholder_9951d0.svg如您所見,前兩張圖片已加載,其余圖片未加載。謝謝大家!
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號