Skip to content
Advertisement

How to put each link separate in database with beautifulsoup python

Hello i would like to add each link seperate in the database. When i print out “new_lst” it displays every link so i think it wants to put the whole outcome in 1 row and now seperate. My code:

JavaScript

Advertisement

Answer

You are already iterating over with a for loop. Yes, it is putting the whole outcome in one line as you are combining them in new_lst = ('"'.join(links)), this can be avoided by just changing to inserting one item at a time that you are looping over already. Though, this approach doesn’t do any checking or validation before putting it into the database, I would add some extra checks if need be before processing the SQL command.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement