I made a dictionary;
mydic = {
'ProductName1': 'mp1',
'ProductName2 : 'mp2',
'ProductName3' : 'mp3',
'ProductName4' : 'mp4'
}
url = "https://www.example.com"
result = requests.get(url)
soup = BeautifulSoup(result.text, "html.parser")
tagnames = soup.find_all("div", {"class": "one-line font-size-md"})
The output is list like this:
[< d i v c l a s s ="o n e - l i n e f o n t - s i z e - m d " > P r o d u c t N a m e 1 < / d i v > , < d i v c l a s s = " o n e - l i n e
f o n t - s i z e - m d " > P r o d u c t N a m e 2 < / d i v > , < d i v c l a s s = " o n e -l i n e f o n t - s i z e - m d " > P r o d u c t N a m e 3 < / d i v > , < d i v c l a s s = " o n e - l i n e f o n t - s i z e - m d " > P r o d u c t N a m e 4 < / d i v > ]
I want to replace ProductName1 with mydic values mp1, mp2 , mp3, mp4 and save html file with replaced. I tried to change the format to string and replace but it couldn't be true.