Solution 1 :

findAll attribute return list , so you should replace each element in the list.

containers = page_soup.findAll("span", {"class":"css-133coio etbu2a32"})

for index, word in enumerate(containers) :
  word = word.replace('%20'," ")
  containers[index] = word
print(containers)

Problem :

I am trying to make a list from my web scraping but any time there’s a space in comes out as ‘%20’. For example, ‘Good Day’ would become ‘Good%20Day’. I tried using replace() but it said that can’t be used on lists. Any ideas? Thanks.

number = 1

while number < 10:

    containers = page_soup.findAll("span", {"class":"css-133coio etbu2a32"})

    container = containers[number]

    con_str = str(container)

    split_str = con_str.split('/browse/')

    split_wrd = split_str[1]

    needWord = split_wrd.split('"')

    final_Word = needWord.replace("%20", " ")

    print(final_Word[0])

    number += 1

code is kinda ghetto but it works.

Comments

Comment posted by AMC

Can you share more of your program, including an example of the HTML or at least the contents of

Comment posted by user-313

yeah i figured it out by finding the [0] of needWord first and then replacing it.

By