私はpythonが初めてです。これを単純化する方法はありますか:
def getDivs():
divs = soup.findAll(name = "div", attrs = {"class" : "resultCell"}, recursive = True)
for div in divs:
h2 = div.find("h2")
a = h2.find("a")
href = a["href"]
yield (href)
divs = list(getDivs())
getDivs の代わりに無名関数を作成できるはずだと思います。(疑似コード) のようなもの:
divs =
[
divs = soup.findAll(name = "div", attrs = {"class" : "resultCell"}, recursive = True)
for div in divs:
h2 = div.find("h2")
a = h2.find("a")
href = a["href"]
yield (href)
]
ありがとう