0

This is my code :

import xlsxwriter
from selenium import webdriver
from selenium.webdriver.common.by import By
chrome_path = r"C:\Users\shoshi\Desktop\אישי\webscraping\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get("https://services.cal-online.co.il/Card-Holders/SCREENS/AccountManagement/Login.aspx?ReturnUrl=%2fcard-holders%2fScreens%2fAccountManagement%2fHomePage.aspx")
user = driver.find_element_by_xpath('//*[@id="ctl00_FormAreaNoBorder_FormArea_lgnLogin_UserName"]')
user.send_keys("xxxx")
passwd = driver.find_element_by_xpath('//*[@id="ctl00_FormAreaNoBorder_FormArea_lgnLogin_Password"]')
passwd.send_keys("xxxx")
driver.find_element_by_xpath('//*[@id="ctl00_FormAreaNoBorder_FormArea_lgnLogin_LoginImageButton"]').click()
driver.find_element_by_xpath('//*[@id="LabelPaymentDetails"]').click()
driver.find_element_by_xpath('//*[@id="lnkToggleFormLink"]/span').click()
driver.find_element_by_xpath('//*[@id="ctl00_FormAreaNoBorder_FormArea_rdoAggregationBySector"]').click()
driver.find_element_by_xpath('//*[@id="ctl00_FormAreaNoBorder_FormArea_ctlSubmitRequest"]').click()



driver.find_element_by_xpath('//*[@id="ctl00_FormAreaNoBorder_FormArea_ctlToggleGrid_lnkExpand"]').click()
posts = driver.find_elements_by_id("ctlMainGrid") 
for post in posts:
    print(post.text)

I getting that result to Terminal screen as below:

שם ענף שם בית עסק מספר עסקות סכום עסקות בש"ח סכום עסקות בדולר מזון 7 ₪ 179.93 מוזה מערכי מזון ואיר 3 ₪ 62.00 אינפורט הגשר בע"מ 2 ₪ 36.00 יציל - פיציולה 1 ₪ 66.93 דובנוב מתוקים 1 ₪ 15.00 ביגוד 5 ₪ 446.50 נעלי האחוזה 1 ₪ 45.00 עזרה ואחוה ברכפלד 1 ₪ 171.70 פוזה הלבשה כללית בעמ 1 ₪ 113.50 זברה יונייטד בע"מ -שילת 2 ₪ 116.30 מוסדות 2 ₪ 178.00 גן החיות התנכי בעמ 1 ₪ 110.00 פארק הקופים 1 ₪ 68.00 פנאי ובילוי 1 ₪ 39.00 י.ע.ע. קפה 443 בע"מ 1 ₪ 39.00 בתי כלבו 1 ₪ 60.00 עיר הילדים בעמ 1 ₪ 60.00 ציוד ומשרד 1 ₪ 479.46 גמא - סטימצקי עזריאלי מוד 1 ₪ 479.46 סה"כ: 17 ₪ 1,382.89

Now I want to save the results to xls or csv file.

How do i do this?

I don't how Write the code..

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125

1 Answers1

0

CSV stands for comma separated values. CSV is like a text file and can be created simply by adding the .CSV extension

for example write this code:

f = open('example.csv','w')
f.write("display,variable x")
f.close()

source:-

Python - Write to Excel Spreadsheet

Hope it will help you :)

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125