# Setting up process clock
import time
from tqdm import tqdm

# Defines the initial start time
start_time = time.time()

# Importing core packages
import pandas as pd
import numpy as np
import requests
from requests_futures.sessions import FuturesSession
from tqdm import tqdm
import matplotlib.pyplot as plt

# Adding pandas progress bar
tqdm.pandas(desc="progress")

# Importing a .csv file named 'url.csv' from the same location as this script
url_df = pd.read_csv("./url.csv")

# Defining functions to apply to url_df
def get_status_code(url):
    try:
        r = requests.get(url, timeout=10)
        return r.status_code 
    except requests.exceptions.RequestException:
        return "Exception"

# Applying functions
if __name__ == "__main__":
        url_df["status_code"] = url_df["url"].progress_apply(get_status_code)
else:
        print("Error!")

# Sending results to a file named 'siteresults.csv' in the same location as this script
url_df.to_csv("./results.csv",sep=',',index=False)

# Makes a summary_df
summary_df = url_df.groupby('status_code')['url'].count().reset_index()
print(summary_df)

# Prints difference between time at end and time at begining i.e. total process time
print("--- %f minutes ---" % ((time.time() - start_time)/60))
406396d572c324291efb1221f8b76d8a4e2682e9
<mask token>


def get_status_code(url):
    try:
        r = requests.get(url, timeout=10)
        return r.status_code
    except requests.exceptions.RequestException:
        return 'Exception'


<mask token>

<mask token>
tqdm.pandas(desc='progress')
<mask token>


def get_status_code(url):
    try:
        r = requests.get(url, timeout=10)
        return r.status_code
    except requests.exceptions.RequestException:
        return 'Exception'


if __name__ == '__main__':
    url_df['status_code'] = url_df['url'].progress_apply(get_status_code)
else:
    print('Error!')
url_df.to_csv('./results.csv', sep=',', index=False)
<mask token>
print(summary_df)
print('--- %f minutes ---' % ((time.time() - start_time) / 60))

<mask token>
start_time = time.time()
<mask token>
tqdm.pandas(desc='progress')
url_df = pd.read_csv('./url.csv')


def get_status_code(url):
    try:
        r = requests.get(url, timeout=10)
        return r.status_code
    except requests.exceptions.RequestException:
        return 'Exception'


if __name__ == '__main__':
    url_df['status_code'] = url_df['url'].progress_apply(get_status_code)
else:
    print('Error!')
url_df.to_csv('./results.csv', sep=',', index=False)
summary_df = url_df.groupby('status_code')['url'].count().reset_index()
print(summary_df)
print('--- %f minutes ---' % ((time.time() - start_time) / 60))

import time
from tqdm import tqdm
start_time = time.time()
import pandas as pd
import numpy as np
import requests
from requests_futures.sessions import FuturesSession
from tqdm import tqdm
import matplotlib.pyplot as plt
tqdm.pandas(desc='progress')
url_df = pd.read_csv('./url.csv')


def get_status_code(url):
    try:
        r = requests.get(url, timeout=10)
        return r.status_code
    except requests.exceptions.RequestException:
        return 'Exception'


if __name__ == '__main__':
    url_df['status_code'] = url_df['url'].progress_apply(get_status_code)
else:
    print('Error!')
url_df.to_csv('./results.csv', sep=',', index=False)
summary_df = url_df.groupby('status_code')['url'].count().reset_index()
print(summary_df)
print('--- %f minutes ---' % ((time.time() - start_time) / 60))

# Setting up process clock
import time
from tqdm import tqdm

# Defines the initial start time
start_time = time.time()

# Importing core packages
import pandas as pd
import numpy as np
import requests
from requests_futures.sessions import FuturesSession
from tqdm import tqdm
import matplotlib.pyplot as plt

# Adding pandas progress bar
tqdm.pandas(desc="progress")

# Importing a .csv file named 'url.csv' from the same location as this script
url_df = pd.read_csv("./url.csv")

# Defining functions to apply to url_df
def get_status_code(url):
    try:
        r = requests.get(url, timeout=10)
        return r.status_code 
    except requests.exceptions.RequestException:
        return "Exception"

# Applying functions
if __name__ == "__main__":
        url_df["status_code"] = url_df["url"].progress_apply(get_status_code)
else:
        print("Error!")

# Sending results to a file named 'siteresults.csv' in the same location as this script
url_df.to_csv("./results.csv",sep=',',index=False)

# Makes a summary_df
summary_df = url_df.groupby('status_code')['url'].count().reset_index()
print(summary_df)

# Prints difference between time at end and time at begining i.e. total process time
print("--- %f minutes ---" % ((time.time() - start_time)/60))