I'm trying to store some data into dict but the key are same for all values, i tried update()
but update ignore if the key already present in the dict. Wold be great if someone explain how to append data with same key value!
Here is the code i'm trying
from bs4 import BeautifulSoup
import requests
data = {}
proxy_url = 'https://free-proxy-list.net/'
req = requests.get(proxy_url)
soup = BeautifulSoup(req.content,'lxml')
table = soup.findAll('table')[0].findAll('tr')
for i in table:
ip = i.select('td:nth-of-type(1)')
port = i.select('td:nth-of-type(2)')
if ip:
ipx = ip[0].text
if port:
portx = port[0].text
proxy = ('http//'+ipx+':'+portx).encode('utf-8')
data.update({'http':proxy})
print(data)
The output dict i want:
data = {
'http': 'http://10.10.1.10:3128',
'http': 'http://10.10.1.10:1080',
}