[閒聊] 請教如何抓class下面的資訊
各位大大晚安,想請教如何可以正確爬得正確資訊
[in]
import urllib.parse
import requests
import time
import json
import os
from bs4 import BeautifulSoup
url =
'https://tw.mall.yahoo.com/store/%E5%B1%88%E8%87%A3%E6%B0%8FWatsons:watsons'
USER_AGENT_VALUE = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
headers = {'User-Agent': USER_AGENT_VALUE}
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.text, 'html.parser')
b = soup.find_all(class_='sc-hzMMVR gYfXYo')
print(b)
[out]
[]
請問為何會抓不到class下面的內容呢? 但是改用selenium.webdriver又可以了?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.25.201.214 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1637248349.A.A66.html
※ 編輯: garlic774 (114.25.201.214 臺灣), 11/18/2021 23:20:29
→
11/19 02:00,
3年前
, 1F
11/19 02:00, 1F
→
11/19 03:13,
3年前
, 2F
11/19 03:13, 2F
→
11/19 03:13,
3年前
, 3F
11/19 03:13, 3F
Python 近期熱門文章
PTT數位生活區 即時熱門文章