[問題] 請教如何爬取分頁連結

作者: garlic774 (蒜頭)   2021-11-14 16:13:27
各位大大午安,小弟想爬取分頁連結,可是一直回饋出現TypeError:
'NoneType' object is not subscriptable,請問應該是哪裡出問題了呢? 謝謝
[in]:
!pip install selenium
from selenium import webdriver
import time
import pandas as pd
browser = webdriver.Chrome(executable_path='./chromedriver.exe')
browser.get("https://tw.mall.yahoo.com/store/%E5%B1%88%E8%87%A3%E6%B0%8FWatsons:watsons")
source = browser.page_source
import time
import requests
from bs4 import BeautifulSoup
soup = BeautifulSoup(source)
links = []
for b in soup.find_all(class_="sc-eHfRjS jzRrlK"):
links.append(b.a['href'])
print(links)
作者: lycantrope (阿寬)   2021-11-14 18:45:00
b.a is None所以跳出not subscripable

Links booklink

Contact Us: admin [ a t ] ucptt.com