<a href = "Link Address" > How do I get it? [Scraping Project] TypeError: 'NoneType' object is not writable

Asked 2 years ago, Updated 2 years ago, 53 views

Trying to get the link address of href, the attribute of tack a, in the Html statement.

The following error continues to appear in the code I made.

    b = b.a['href']
TypeError: 'NoneType' object is not subscriptable

What's wrong?

The code is shown below.

browser.get("http://www.albamon.co.kr/")

alba = BeautifulSoup(browser.page_source, 'html.parser')

brands = alba.find(id = "MainSuperBrand").find_all("li")

for b in brands :

b = b.a['href']

print(b)

scraping python html css crawling

2022-09-20 12:31

1 Answers

You have to bring the tag a.

brands = alba.find(id ='MainSuperBrand').find_all('a')

for b in brands :
    print(b['href'])


2022-09-20 12:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.