Skip to content

Commit 5ce4f61

Browse files
committed
Fix link extraction logic in workshop dictionary - is not necessary to iterate over h3 again to get the link
1 parent 5d4d63c commit 5ce4f61

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

episodes/a-real-website.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ workshop_list = []
252252
for item in divs:
253253
dict_workshop = {}
254254
dict_workshop['host'] = item.find('h3').get_text()
255-
dict_workshop['link'] = item.find('h3').find('a').get('href') # get is used to access attribute values as a dictionary
255+
dict_workshop['link'] = item.find('a').get('href') # get is used to access attribute values as a dictionary
256256
dict_workshop['curriculum'] = item.get('data-curriculum')
257257
dict_workshop['country'] = item.get('data-country')
258258
dict_workshop['format'] = item.get('data-meeting')
@@ -283,7 +283,7 @@ workshop_list = []
283283
while child_div is not None:
284284
dict_workshop = {}
285285
dict_workshop['host'] = child_div.find('h3').get_text()
286-
dict_workshop['link'] = child_div.find('h3').find('a').get('href')
286+
dict_workshop['link'] = child_div.find('a').get('href')
287287
dict_workshop['curriculum'] = child_div.get('data-curriculum')
288288
dict_workshop['country'] = child_div.get('data-country')
289289
dict_workshop['format'] = child_div.get('data-meeting')
@@ -325,7 +325,7 @@ workshop_list = []
325325
for item in divs_past:
326326
dict_workshop = {}
327327
dict_workshop['host'] = item.find('h3').get_text()
328-
dict_workshop['link'] = item.find('h3').find('a').get('href')
328+
dict_workshop['link'] = item.find('a').get('href')
329329
dict_workshop['curriculum'] = item.get('data-curriculum')
330330
dict_workshop['country'] = item.get('data-country')
331331
dict_workshop['format'] = item.get('data-meeting')
@@ -362,7 +362,7 @@ We only need to add three lines to our loop, and this is how it would look like.
362362
for item in divs:
363363
dict_workshop = {}
364364
dict_workshop['host'] = item.find('h3').get_text()
365-
dict_workshop['link'] = item.find('h3').find('a')['href']
365+
dict_workshop['link'] = item.find('a')['href']
366366
dict_workshop['curriculum'] = item.get('data-curriculum')
367367
dict_workshop['country'] = item.get('data-country')
368368
dict_workshop['format'] = item.get('data-meeting')

0 commit comments

Comments
 (0)