from bs4 import BeautifulSoup a = """ DecrepitSewersIcon.png Decrepit Sewers 9 -919 -1883 Sewers of Ragni InfestedPitIcon.png Infested Pit 18 -171 -1820 Arachnids' Ascent LostSanctuaryIcon.png Lost Sanctuary 24 -262 -1045 Studying the Corrupt UnderworldCryptIcon.png Underworld Crypt 27 227 -1950 The Dark Descent Sand-SweptTombIcon.png Sand-Swept Tomb 36 1409 -1830 Kingdom of Sand IceBarrowsIcon.png Ice Barrows 45 117 -667 Fate of the Fallen UndergrowthRuinsIcon.png Undergrowth Ruins 54 -660 -835 Corrupted Betrayal GalleonsGraveyardIcon.png Galleon's Graveyard 63 -583 -3468 Redbeard's Booty CorruptedDecrepitSewers.png Corrupted Decrepit Sewers 70 -860 -4900 None CorruptedInfestedPit.png Corrupted Infested Pit 74 -860 -4900 None DungeonIcon.png Corrupted Lost Sanctuary 78 -860 -4900 None DungeonIcon.png Corrupted Underworld Crypt 82 -860 -4900 None DungeonIcon.png Corrupted Sand-Swept Tomb 86 -860 -4900 None Corkusdungeonlogosmall.png Fallen Factory 90 Unknown -1675 -2600 The Envoy Part II DungeonIcon.png Corrupted Ice Barrows 90 -860 -4900 None DungeonIcon.png Corrupted Undergrowth Ruins 94 -860 -4900 None EldritchOutlookIcon.png Eldritch Outlook 101 Unknown -1310 -777 A Journey Further """ h = BeautifulSoup(a, 'html.parser') tr = h.find_all("tr") for t in tr: tds = t.find_all("td") try: print("{\"minlevel\": %s, \"name\": \"%s\", \"url\": \"https://wynncraft.gamepedia.com%s\", \"location\": \"%s, %s\"}," % (tds[2].text.replace("\n", ""), tds[1].text.replace("\n", ""), tds[1].a["href"].replace("\n", ""), tds[23].text.replace("\n", ""), tds[24].text.replace("\n", ""))) except: continue