0

I want b to have all the x[”src”] content then put all that content in text.txt file, but when i run it, it only shows
.

a single line of ’src’ in that file. https://code.sololearn.com/cfnzBtDkr3c5/?ref=app

10th May 2022, 3:15 PM
Lenoname
2 Answers
+ 1
1) I'm a total noob. I don't know an iota about this module and have forgotten most of the stuff I'd learned here about HTML, but, maybe you can try this. i = soup.find_all('img') b = [] for x in i: b.append(x['src']) print('\n '.join(b)) You haven't really used your for loop to aggregate what you got at each iteration into a single object. And by the way sorry if I'm failing to understand but it seems to me that while loop is a bit questionable. Why is it not broken out of, where's the predicate? You call inserin() if 1 and view() if 2, when you call it and collect all the sources for your images from your soup of an html source code, I'm guessing, you're hoping to ask for another input for another URL? is that why the while loop is there? if that’s why, you don't need input() below inserin() (under while), it's gonna keep asking if 1 or 2 anyway unless you add a predicate to break out of it, such as,
20th May 2022, 12:29 AM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
2) such as, else: break Again, I'm sorry if I'm mistaken or I've failed to undestand what this is, but you had asked this question twice and neither had answers, I wanted to give it a shot, both to learn a bit and see if I notice something useful to you. I hope somebody who really knows their thing helps you. So this could function as a bump, too, if they notice it and come to the rescue, perhaps. Have a nice day.
20th May 2022, 12:33 AM
Korkunç el Gato
Korkunç el Gato - avatar