title: Python - Beautiful Soup - How do i extract a single piece of text out of a tag
body: <p>at first I want to let you know, that I'm a total newbie in terms of python and web crawling.
  I try to implement a crawler on coinmarketcap.com with BeautifulSoup.</p>
  <p>The dom-tree for the name of the coin looks like this:</p>
  <pre><code>&lt;h2 class=&quot;sc-1q9q90x-0 jCInrl h1&quot; color=&quot;text&quot;&gt;Polygon&lt;small class=&quot;nameSymbol&quot;&gt;MATIC&lt;/small&gt;&lt;/h2&gt;
  </code></pre>
  <p>My code to extract the name looks like this:</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  from urllib.parse import urljoin
  
      def get_name(url):
          start_url = &quot;https://coinmarketcap.com/all/views/all/&quot;
          url = urljoin(start_url, url)
          response =  requests.get(url)
          soup = BeautifulSoup(response.text, &quot;html.parser&quot;)
          name = soup.find('h2', class_=&quot;sc-1q9q90x-0 jCInrl h1&quot;).text[0]
          print(name)
          
      url = &quot;https://coinmarketcap.com/all/views/all/&quot;
      website = requests.get(url)
      results = BeautifulSoup(website.text, &quot;html.parser&quot;)
      counter = 0
      table = results.find('tbody')
      for row in table.find_all('tr'):
          found_coins = []
          if counter == 10:
              break
          else:
              try:
                  url = row.find(&quot;a&quot;, class_=&quot;cmc-link&quot;).attrs[&quot;href&quot;]
                  name = get_name(url)
              except AttributeError:
                  continue
  </code></pre>
  <p>(edited: All of the Code is shown now.)</p>
  <p>The output or the function looks like this:</p>
  <pre><code>BitcoinBTC
  EthereumETH
  Binance CoinBNB
  TetherUSDT
  SolanaSOL
  CardanoADA
  XRPXRP
  PolkadotDOT
  USD CoinUSDC
  DogecoinDOGE
  </code></pre>
  <p>So as you can see, the text of the h2-tag gets combined with the text of the small-tag.</p>
  <p>How can i extract only the first piece of text out of the h2-tag?</p>
  <p>I appreciate your help, thanks in advance!</p>