areaDict = {
"id": "",
"name": "",
"urls": [["", ""], ["", ""]],
}
areas = []
def getCouncils():
page = requests.get('https://profile.id.com.au/')
soup = BeautifulSoup(page.content, 'html.parser') #Parsing content
links = soup.select("a.councilCard")
id = 0
for anchor in links:
areaInfo = dict(areaDict)
areaInfo['id'] = id
id += 1
areaInfo['name'] = anchor.text.strip() #Strip gets rid of new line characters
areaInfo['urls'][0][0] = "profileID"
areaInfo['urls'][0][1] = anchor['href']
areas.append(areaInfo)
#print(anchor['href'])
When I uncomment that print statement, it prints out the correct string that I am after, however when printing the entire 'areas' list, all of the urls are the href from the last anchor in links. I am assuming this has something to do with Pythons memory storage but I am unsure of how to fix it. Thankyou.