Beautifulsoup为href返回没有值如何选择它?

时间:2017-05-06 20:12:02

标签: python beautifulsoup

如何从左侧的Remixed From部分获取hrefs以用于以下页面

webpage = 'http://www.thingiverse.com/thing:1492411'

我尝试过类似的事情:

response = requests.get('http://www.thingiverse.com/thing:1492411')
soup = BeautifulSoup(response.text, "lxml")
remm = soup.find_all("a", class_="thing-stamp")
for rems in remm:
    adress = rems.find("href")
    print(adress)

当然没有工作

编辑:HTML标记如下所示:

<a class="thing-stamp" href="/thing:1430125">
<div class="stamp-content">
<img alt="" class="render" src="https://cdn.thingiverse.com/renders/57/ea/1b/cc/c2/1105df2596f30c4df6dcf12ca5800547_thumb_small.JPG"/> <div>Anet A8 button guide by Simhopp</div>
</div>
</a>
<a class="thing-stamp" href="/thing:1430727">
<div class="stamp-content">
<img alt="" class="render" src="https://cdn.thingiverse.com/renders/93/a9/c8/45/da/05fe99b5215b04ec33d22ea70266ac72_thumb_small.JPG"/> <div>Frame brace for Anet A8 by Simhopp</div>
</div>
</a>

1 个答案:

答案 0 :(得分:2)

尝试:

remm = soup.find_all("a", class_="thing-stamp")
for rems in remm:
    adress = rems.get('href')
    print(adress)