title: Web scraping data using Python Beautiful Soup - can't extract field
body: <p>I am trying to extract the ticker (South Africa 40) field from an IG Index page using Python Beautiful Soup, but I can't retrieve it.</p>
  
  <p>The webpage I am trying to get data from is <a href="https://www.ig.com/uk/ig-indices/south-africa-40?siteId=igm" rel="nofollow noreferrer">https://www.ig.com/uk/ig-indices/south-africa-40?siteId=igm</a></p>
  
  <p>HTML code with the ticker data:</p>
  
  <pre><code>&lt;div class="ma-content title"&gt;
      &lt;h1&gt;South Africa 40&lt;/h1&gt;
  
          &lt;p&gt;
              .........some text..........
          &lt;/p&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>name = soup.select('div.ma-content title h1')[0].text
  </code></pre>
  
  <p>but get the error message:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File
    "IGIndexDataScrape_Minute_v0.1.py", line 30, in 
        name = soup.select('div.ma-content title h1')[0].text IndexError: list index out of range</p>
  </blockquote>
  
  <p>Any advice / code correction on the above will be really helpful.</p>
  
  <p>Here is the complete code for straight copy and paste:</p>
  
  <pre><code>import urllib2
  from bs4 import BeautifulSoup
  
  import csv
  from datetime import datetime
  
  from lxml import html
  import requests
  
  quote_page = ['https://www.ig.com/uk/ig-indices/south-africa-40?siteId=igm']
  
  data = []
  for pg in quote_page:
  page = urllib2.urlopen(pg)
  
  soup = BeautifulSoup(page, 'html.parser')
  
  name = soup.select('div.ma-content title h1')[0].text
  
  sell_price = soup.find('span', attrs={'class':'price', 'id':'bid'}).text
  data.append(sell_price)
  
  buy_price = soup.find('span', attrs={'class':'price', 'id':'ofr'}).text
  data.append(buy_price)
  
  print sell_price + "\t\t" + buy_price + name
  
  #    data.append(name, sell_price, buy_price)
  #    print name + "\t\t" + sell_price + "\t\t" + buy_price
  </code></pre>