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

看板Python作者 (蒜頭)時間3年前 (2021/11/14 16:13), 編輯推噓1(100)
留言1則, 1人參與, 3年前最新討論串1/1
各位大大午安,小弟想爬取分頁連結,可是一直回饋出現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) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.25.223.98 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1636877609.A.354.html

11/14 18:45, 3年前 , 1F
b.a is None所以跳出not subscripable
11/14 18:45, 1F
文章代碼(AID): #1XaCKfDK (Python)
文章代碼(AID): #1XaCKfDK (Python)