[问题] 请教如何爬取分页连结

楼主: 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