【问题标题】:Select a specific URL with BeautifulSoup [duplicate]使用 BeautifulSoup 选择特定 URL [重复]
【发布时间】:2020-11-07 19:26:44
【问题描述】:

我有以下汤

 </title>
  <meta content="Erfahre aus erster Hand, ob xxx als Arbeitgeber zu dir passt. 21 Erfahrungsberichte von Mitarbeitern liefern dir die Antwort." name="description"/>
  <link href="https://www.kununu.com/de/xxx/kommentare/3" rel="next"/>
  <link href="https://www.kununu.com/de/xxx/kommentare" rel="prev"/>
  <link href="https://www.kununu.com/de/xxx/kommentare/2" rel="canonical"/>
  <script type="application/ld+json">

我想选择属性为“next”的 URL

<link href="https://www.kununu.com/de/xxx/kommentare/3" rel="next"/>

我该怎么做?

【问题讨论】:

标签: python web-scraping beautifulsoup


【解决方案1】:
soup = BeautifulSoup(html)
results = soup.findAll("link", {"rel" : "next"})

for result in results:
   if result.has_attr('href'):
      print(link['href'])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-07
    • 2019-04-20
    • 1970-01-01
    • 2011-11-28
    • 2021-08-02
    • 2014-01-04
    • 2017-01-23
    • 1970-01-01
    相关资源
    最近更新 更多