我得到的结果如下:
<a class="ellipsis" href="https://www.link.com" title="Name of the hyperlink ">Name of the hyperlink </a>
我只想提取一个变量(例如link)的链接,以及另一个变量(例如name)的名称。 这是到目前为止我的代码
def supa(linko):
r = get(linko, headers=ua)
return BeautifulSoup(r.content, 'html.parser')
soup = supa(base_url + search)
the_icons = soup.find_all('div', class_='caption')
for icon in the_icons:
name = icon.find('a', class_='ellipsis')
print(name)
您只需在查找的末尾添加['href']:
相关问题 更多 >
编程相关推荐