import logging

from bs4 import BeautifulSoup
from selenium import webdriver

logging.basicConfig(filename='scrape.log', level=20)
logging.info('Initialized logger')


def get_soup_object(html):
    return BeautifulSoup(html)


def get_dynamic_content(link):
    try:
        driver = webdriver.PhantomJS()
        logging.info("Webdriver initiated {0}".format(driver))
    except Exception as exp:
        logging.fatal("Webdriver exception: {exception}".format(exception=exp))
        raise exp
    driver.get(link)
    html = driver.page_source
    soup = get_soup_object(html)
    # Dump the page source to log for debugging purpose, this will work only if level is set to 10 in line number 5
    logging.debug(soup.prettify())
    parsedata(soup)


def parsedata(soup):
    victims = soup.find_all("div", {"class": "homicide"})
    for victim in victims:
        # Set default values as NA for each victim
        date = name = age = race = cause = neighbourhood = time = addr = "NA"
        try:
            date = victim.find("div", {"class": "date"}).get_text().strip()
        except Exception as exp:
            pass
        try:
            name = victim.find("h2", {"class": "name"}).get_text().strip()
        except Exception as exp:
            pass
        try:
            age = victim.find("div", {"class": "age"}).contents[1].strip()
        except Exception as exp:
            pass
        try:
            race = victim.find("div", {"class": "race"}).contents[1].strip()
        except Exception as exp:
            pass
        try:
            cause = victim.find("div", {"class": "cause"}).contents[1].strip()
        except Exception as exp:
            pass
        try:
            neighbourhood = victim.find("div", {"class": "neighborhood"}).contents[1].strip()
        except Exception as exp:
            pass
        try:
            time = victim.find("span", {"class": "murder_time"}).get_text().strip()
        except Exception as exp:
            pass
        try:
            addr = victim.find("div", {"class": "address"}).contents[2].strip()
        except Exception as exp:
            pass
        print "Date " + date + " Name " + name + " Age " + age + " Race " + race + " Cause " + cause + " Neigbourhood " + neighbourhood + " Time " + time + " Address " + addr


for year in range(2012, 2018):
    for month in range(1, 13):
        link = "https://www.dnainfo.com/chicago/{}-chicago-murders/timeline?mon={}".format(str(year), str(month))
        get_dynamic_content(link)

@@ -8,16 +8,46 @@
 logging%0A
+import os%0A%0Aimport pandas as pd
 %0Afrom bs
@@ -993,16 +993,23 @@
 rhood = 
+murder_
 time = a
@@ -1898,16 +1898,23 @@
         
+murder_
 time = v
@@ -2161,32 +2161,783 @@
             pass
+%0A%0A        victim_info = %7B'name': name,%0A                       'date': date,%0A                       'age': age,%0A                       'race': race,%0A                       'cause': cause,%0A                       'neighbourhood': neighbourhood,%0A                       'time': murder_time,%0A                       'address': addr%0A                       %7D%0A%0A        victim_info_df = pd.DataFrame(victim_info, index=%5B0%5D)%0A%0A        # if file does not exist write header%0A        if not os.path.isfile('victim_info_2012_2018.csv'):%0A            victim_info_df.to_csv('victim_info_2012_2018.csv', header=True)%0A        else:  # else it exists so append without writing the header%0A            victim_info_df.to_csv('victim_info_2012_2018.csv', mode='a', header=False)
 %0A        print %22
@@ -3070,16 +3070,23 @@
 ime %22 + 
+murder_
 time + %22

Use pandas and save data to CSV