title: How do I take a list of urls that are stored in a csv file and import them to python to scrape and export back to csv with newly gathered data
body: <p>I am very new to python and BeautifulSoup and I am trying to use it to scrape multiple urls at the same time using a loop. The loop will consist of locating the banner slide on the home page of each website and get the len of how many banners that website has and place them into an excel file next to the corresponding url. I have a list of urls saved in a csv file and basically what I want to do is take each of those urls and run the loop, pulling the number of banners, and put that number next to the url into a separate column in excel. </p>
  
  <p>This is the code I have so far and all it does for me is write the urls back into a csv file and gives me the number of banners for only the last url.   </p>
  
  <pre><code>from bs4 import BeautifulSoup 
  import requests
  
  with open("urls.csv", "r") as f:
  csv_raw_cont=f.read()
  
  split_csv=csv_raw_cont.split('\n')
  
  split_csv.remove('')
  
  separator=';'
  
  filename = "DDC_number_of_banners.csv"
  f = open(filename, "w")
  
  headers = "url, Number_of_Banners\n"
  
  f.write(headers)
  
  for each in split_csv:
      url_row_index=0
      url = each.split(separator)[url_row_index]
      html = requests.get(url).content
      soup= BeautifulSoup(html, "html.parser")
  
      banner_info = soup.findAll('div',{'class':['slide', 'slide has-link', 
  'html-slide slide has-link']})
  
      Number_of_banners = len(banner_info)
  
  f.write(csv_raw_cont + "," + str(Number_of_banners) + "," + "\n")
  
  f.close()
  </code></pre>