title: Issue in scraping data in bs4
body: <p>I want to scrape data from this website: &quot;https://sephora.ae&quot;
  and I have written this code</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  import json
  
  
  
  def sephora(URL):
      # opening our output file in append mode
      File = open(&quot;out.csv&quot;, &quot;a&quot;)
      print(&quot;function start&quot;)
      # specifying user agent, You can use other user agents
      # available on the internet
      print(URL)
      HEADERS = ({'User-Agent': 
             'Mozilla/5.0 (X11; Linux x86_64)                  AppleWebKit/537.36 (KHTML, like Gecko)                     Chrome/44.0.2403.157 Safari/537.36', 
                             'Accept-Language': 'en-US, en;q=0.5'}) 
   
      
      # Making the HTTP Request 
      webpage = requests.get(URL, headers=HEADERS)  
      
      # Creating the Soup Object containing all data 
      soup = BeautifulSoup(webpage.content, 'html.parser')
      print(&quot;a&quot;)
  
  
  
      #brand name
      try:
          brand = soup.find_all('span', {&quot;class&quot;: &quot;brand-name&quot;})
      except AttributeError:
          brand = 'NA'
  
      #Product Name
      try:
          prname = soup.find_all('meta', {&quot;itemprop&quot;: &quot;name&quot;})[&quot;content&quot;].text
      except AttributeError:
          prname = 'NA'
  
      #price
      try:
          price = soup.find_all('meta', {&quot;itemprop&quot;: &quot;price&quot;})[&quot;content&quot;].text
      except AttributeError:
          price = 'NA'
  
      #price currency
      try:
          price_cur = soup.find_all(
              'meta', {&quot;itemprop&quot;: &quot;priceCurrency&quot;})[&quot;content&quot;].text
      except AttributeError:
          price_cur = 'NA'
  
      #item code
      try:
          item_code = soup.find_all('meta', {&quot;itemprop&quot;: &quot;sku&quot;})[&quot;content&quot;].text
      except AttributeError:
          item_code = 'NA'
  
      #variant url
      try:
          urll = soup.find_all('meta', {&quot;itemprop&quot;: &quot;url&quot;})[&quot;content&quot;].text
      except AttributeError:
          urll = 'NA'
  
      #category
      try:
          category = soup.find_all('span', {&quot;class&quot;: &quot;product-name&quot;}).text
      except AttributeError:
          category = 'NA'
  
      #size
      try:
          size = soup.find_all('img', {&quot;class&quot;: &quot;variation-image&quot;})[&quot;alt&quot;].text
      except AttributeError:
          size = 'NA'
  
      #image_src
      image_tags = soup.find_all(&quot;a&quot;, {&quot;class&quot;: &quot;variation-display-name&quot;},
                                 {&quot;rel&quot;: &quot;nofollow&quot;})
      imagess = image_tags[&quot;data-lgimg&quot;]
      res = json.loads(imagess)
      img_src = res['url']
      img_title = res['title']
      img_alt = res['alt']
  
      #description
      try:
          desc_div = soup.find_all('div', {&quot;class&quot;: &quot;product-description-box&quot;})
      except AttributeError:
          desc_div = 'NA'
      
      # print(img_src)
      print(img_alt)
      # print(Item_code)
      # print(Size)
      File.write(f&quot;{URL};&quot;)
      File.write(f&quot;{brand};&quot;)
      File.write(f&quot;{prname};&quot;)
      File.write(f&quot;{category};&quot;)
      File.write(f&quot;{urll};&quot;)
      File.write(f&quot;{desc_div};&quot;)
      # File.write(f&quot;{ingredients};&quot;)
      File.write(f&quot;{price};&quot;)
      File.write(f&quot;{price_cur};&quot;)
      File.write(f&quot;{img_src};&quot;)
      File.write(f&quot;{img_title};&quot;)
      File.write(f&quot;{item_code};&quot;)
      File.write(f&quot;{size}\n&quot;)
  
  
  if __name__ == '__main__':
      # opening our url file to access URLs
      print(&quot;start&quot;)
      file = open(&quot;url.txt&quot;, &quot;r&quot;)
      header = &quot;URL;BRAND;NAME;VARIANT LINK;DESCRIPTION;PRICE;PRICE CUR;IMG;TITLE;ITEMCODE;SIZE&quot;
      File = open(&quot;out.csv&quot;, &quot;w&quot;)
      File.write(f&quot;{header}\n&quot;)
      File.close()
  
      URLs = file.readlines()
     
      for links in URLs:
          sephora(links)
      File.close()
  
  </code></pre>
  <p>but in out.csv, only the headers are coming and nothing else when I am running with repl.it.
  And when I am running with cmd, then this error is coming</p>
  <pre><code>C:\Users\Admin\Desktop\sephora&gt;python main.py
  Traceback (most recent call last):
    File &quot;C:\Users\Admin\Desktop\sephora\main.py&quot;, line 137, in &lt;module&gt;
      sephora(links)
    File &quot;C:\Users\Admin\Desktop\sephora\main.py&quot;, line 33, in sephora
      prname = soup.find_all('meta', {&quot;itemprop&quot;: &quot;name&quot;})[&quot;content&quot;]
  TypeError: list indices must be integers or slices, not str
  </code></pre>
  <p>Kindly help me to solve this issue</p>
  <p>I am using this URL for starting</p>
  <p><a href="https://www.sephora.ae/en/p/color-lip-last-lipstick-P1074023.html" rel="nofollow noreferrer">https://www.sephora.ae/en/p/color-lip-last-lipstick-P1074023.html</a></p>
  <p>Thank you</p>