I am trying to get the id of respective movie name in that i need to check whether the url is working or not . If not then i need to append the movie name in the empty list

```
data = {'id': [nan, nan, nan,nan],
            'movie_name': ['captain-fantastic', 'passengers', 'transformers','guardians-of-the-galaxy-vol-2']}

data2 = {'id': [nan, nan, nan,nan],
        'movie_name': ['captain-fantastic', 'passengers', 'transformers','guardians-of-the-galaxy-vol.2']}

dfa = pd.DataFrame(data)
dfa2 = pd.DataFrame(data2)

from turtle import clear
from urllib.request import Request, urlopen
import pandas as pd
import urllib.request as ur, json

movie_buff_uuid= []

for i in dfa["movie_name"]:
    url = ur.urlopen("https://www.moviebuff.com/"+str(i)+".json")
    d = json.loads(url.read())['uuid']
    movie_buff_uuid.append(d)    

```

print(movie\_buff\_uuid)

if i passed the data2 in the above loop i am getting this error urllib.error.HTTPError: HTTP Error 404: Not Found to overcome this error. I have tried this

```
movie_buff_uuid= []

for i in dfa["movie_name"]:
    url = ur.urlopen("https://www.moviebuff.com/"+str(i)+".json")
    if url.getcode() == 404:
       d = json.loads(url.read())['uuid']
    else:
        d = i

movie_buff_uuid.append(d)

print(movie_buff_uuid)

```

Expected output:

```
['f8379c86-1307-4b22-b175-5000284ef6b9', '8f0c611a-4356-454d-a6d6-aac437519540', '7cd2dffa-cb31-4897-a7b0-30dcaee66104', 'guardians-of-the-galaxy-vol.2']

```

Any idea would be appreciated