我如何获取属于div标签内特定类的锚标签的href标签?在python中

时间:2016-10-29 04:50:04

标签: python-3.x beautifulsoup

Python代码:

productLinks = [div.a for div in 
        soup.findAll('div', attrs={'class' : 'a-row a-spacing-none'})]
print(productLinks)
for link in productLinks:
    print(hr.append(link['href']))

错误:

Traceback (most recent call last):
  File "C:\Python34\api.py", line 20, in <module>
    print(hr.append(link['href']))
TypeError: 'NoneType' object is not subscriptable

0 个答案:

没有答案