Issue
how can I remove redundant spacing after I pull some element data with selenium
My output lookslike:
Telefon:
216 593 17 20 - 21 - 22
Websitesi:
http://www.an-ko.com
Email:
[email protected]
and I want to remove spaces from this here's the script I use
from selenium import webdriver
driver = webdriver.Safari()
driver.get("https://iayosb.com/firmalar/anadolu-kompozit-mam-san-ve-tic-a-s/")
article = driver.find_elements_by_xpath("//div[@class='w2dc-fields-group w2dc-fields-group-1']")
for elem in article:
print(elem.text)
driver.quit()
Thanks is advance I really appreciate it
Solution
I'm using pycharm and for trailing spaces I am using replace(' ', '')
. Please see below :
driver.get("https://iayosb.com/firmalar/anadolu-kompozit-mam-san-ve-tic-a-s/")
article = driver.find_elements_by_xpath("//div[@class='w2dc-fields-group w2dc-fields-group-1']")
for elem in article:
print(elem.get_attribute('innerText').replace(' ', ''))
Output :
İLETİŞİMBİLGİLERİ
Telefon:2165931720-21-22
Websitesi:http://www.an-ko.com
Email:[email protected]
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.