Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Output content contains a (\n) new Line, so I can't able to store data in excel? What to do omit the new line in print section?

What I have tried:

for Linkedin_URL in URLs_all_Page:
		driver.get(Linkedin_URL)
		time.sleep(2)

		page_source = driver.page_source
		soup = BeautifulSoup(page_source, "html.parser")

		ExeName = soup.find('dt', {'class':'flex align-items-center'}).find('span', {'class':'profile-topcard-person-entity__name t-24 t-black t-bold'})
		
 -->       soup_ExeName = BeautifulSoup(ExeName.text, 'html.parser')

print(soup_ExeName,"|",soup_PreCompany,"|",soup_NewTitle,"|",soup_Company,"|",soup_tenur)

		   sheet.append([soup_ExeName, soup_PreCompany, soup_NewTitle, soup_Company, soup_tenur])


#---------------------------------------------------------------------------------------#
OutPut:

Masi Amianda
                 | Brandywine Nursing & Rehabilitation Center | Workers Compensation Senior Claim Adjuster | AIG | 
                                10 yrs

Cannot convert 
                    Masi Amianda
                 to Excel
Posted
Updated 8-Dec-21 22:58pm
Comments
Sriram Krishnamoorthy 2021 9-Dec-21 6:46am    
Thank You! Richard.

soup_ExeName = BeautifulSoup(ExeName.text.replace("\n", ""), 'html.parser')


In this how to replace the excess space after Crystal Myers.


OutPut !

Crystal Myers | Solutions Staffing | Workers Compensation Specialist | Installed Building Products |
1 yr
Richard MacCutchan 9-Dec-21 7:36am    
Not sure what you are asking. The replace function can replace any substring in a string with a new value of your choice as described at Built-in Types — Python 3.10.1 documentation[^]. You can also use the 'trim' functions to remove characters from the beginning and/or end of a string.

1 solution

You need to use the string replace function to replace the newline with nothing:
Python
soup_ExeName = soup_ExeName.replace("\n", "")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900