Search code examples
pythonpandasdataframeweb-scrapingexport-to-excel

Why &nbsp replace as A in excel while scrape data from website in python , I am trying to solve it with .replace(' ',"") but still not working


I am using python, Here is my code and screenshot enter image description here

Category = soup.find('a', class_='article-labels__text b-reith-sans-font').text.replace(' ',"").replace('|',"")

print("""\n""") print("Category: ", Category )


Solution

  • Try to use .get_text() method instead of .text property

    Category = soup.find('a', class_='article-labels__text b-reith-sans-font').get_text(strip=True)