1
なぜこのコードは検索エンジンで見つかった3つのヒットに3つのリンクを出力しないのですか?beautifulsoup未分類リストからhrefを取得
from bs4 import BeautifulSoup
from urllib import urlopen
import urllib2
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
url = "https://www.conrad.de/de/Search.html?search=mosfet+driver"
page = opener.open(url)
soup = BeautifulSoup(page, "html5lib")
#print soup.prettify
result = soup.find_all('ul', class_="ccpProductList")
products = result[0].find_all('a', class_="ccpProductListItem__title")
for product in products:
print product.href
出力が「なし」の3回です。
この質問に似ています:http://stackoverflow.com/questions/7183922/extracting-href-with-beautiful-soup – skmathur