Upload files to "/"
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
import requests
|
||||
import string
|
||||
import re
|
||||
import time
|
||||
import xlwings as xw
|
||||
import argparse
|
||||
import os
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
def dir_path(path):
|
||||
if os.path.isdir(path):
|
||||
return path
|
||||
else:
|
||||
raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path")
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-f",type=str,default='redbook.xlsm')
|
||||
parser.add_argument("-w",type=str,default='Sheet1')
|
||||
parser.add_argument("-u")
|
||||
parser.add_argument("-r",type=str,default='https://www.vrbo.com/rm/321.2072585.2637118/conversation/253dca60-0988-4191-ab23-91f635016e07')
|
||||
parser.add_argument("-username",default='*******')
|
||||
parser.add_argument("-password",default='*******')
|
||||
args = parser.parse_args()
|
||||
print(args)
|
||||
|
||||
gecko_path = 'C:/temp/geckodriver.exe'
|
||||
options = webdriver.firefox.options.Options()
|
||||
options.headless = False
|
||||
driver = webdriver.Firefox(options = options, executable_path = gecko_path)
|
||||
url = args.r
|
||||
driver.get(url)
|
||||
time.sleep(2)
|
||||
username = driver.find_element_by_id("lex-emailAddress")
|
||||
username.send_keys(args.username)
|
||||
password = driver.find_element_by_id("password")
|
||||
password.send_keys(args.password)
|
||||
|
||||
time.sleep(1)
|
||||
driver.find_element_by_id("login").click()
|
||||
time.sleep(4)
|
||||
|
||||
#alert = driver.switch_to.alert
|
||||
#alert.dismiss();
|
||||
|
||||
#try:
|
||||
# element = WebDriverWait(driver, 10).until(
|
||||
# EC.presence_of_element_located((By.CLASS_NAME, "MessageItem MessageItem--payout"))
|
||||
# )
|
||||
#finally:
|
||||
# driver.quit()
|
||||
time.sleep(10)
|
||||
pageSource = driver.page_source
|
||||
fileToWrite = open("page_source.html", "w")
|
||||
fileToWrite.write(pageSource)
|
||||
fileToWrite.close()
|
||||
|
||||
BookingDetailsdates=driver.find_element_by_class_name("BookingDetails__dates")
|
||||
Ledgeritemvalue=driver.find_elements_by_class_name("Ledger-item__value")
|
||||
PaymentSchedule__amount=driver.find_element_by_class_name("PaymentSchedule__amount")
|
||||
NumNightsandGuests=driver.find_element_by_css_selector('.MessageItem--nightAndGuests')
|
||||
adNum=driver.find_element_by_css_selector('.ha-partner-property-selector-property-details')
|
||||
guestName=driver.find_element_by_class_name('h4')
|
||||
Property=driver.find_element_by_class_name('BookingDetails__info')
|
||||
|
||||
EstimatedPayout = Ledgeritemvalue[0].text
|
||||
BookingAmount = Ledgeritemvalue[1].text
|
||||
FullPayment = PaymentSchedule__amount.text
|
||||
Ad = adNum.text
|
||||
Guest = guestName.text
|
||||
Prop = Property.text
|
||||
BookingDetails = str(BookingDetailsdates.text).strip() #Body1 = str(soup.text).strip()
|
||||
for index,line in enumerate(BookingDetails.splitlines()):
|
||||
if line.startswith("Check in") :
|
||||
Checkin=BookingDetails.splitlines()[index+1]
|
||||
if line.startswith("Check out") :
|
||||
Checkout=BookingDetails.splitlines()[index+1]
|
||||
numnights = (NumNightsandGuests.text).strip().splitlines
|
||||
NNights=(NumNightsandGuests.text).strip().splitlines(0)[0]
|
||||
Guests=(NumNightsandGuests.text).strip().splitlines(0)[1]
|
||||
driver.close()
|
||||
|
||||
print ("Estimated Payout: ",EstimatedPayout)
|
||||
print ("Booking amount : ",BookingAmount)
|
||||
print ("Full Payment: ",FullPayment)
|
||||
print ("Ad # : ",Ad)
|
||||
print ("Guest : ",Guest)
|
||||
print ("Property : ",Prop)
|
||||
print ("Check-in: ",Checkin)
|
||||
print ("Check-out: ",Checkout)
|
||||
print ("Num Nights: ",NNights)
|
||||
print ("Guests: ",Guests)
|
||||
|
||||
|
||||
location = str(args.f)
|
||||
wb = xw.Book(location) # connect to a file that is open or in the current working directory
|
||||
sheet = wb.sheets[args.w]
|
||||
sheet.range('F2').value = Guest
|
||||
sheet.range('D7').value = Prop
|
||||
sheet.range('D8').value = Ad
|
||||
sheet.range('D9').value = ''
|
||||
sheet.range('D10').value = Guests
|
||||
sheet.range('D11').value = Checkin
|
||||
sheet.range('D12').value = ''
|
||||
sheet.range('D13').value = Checkout
|
||||
sheet.range('D14').value = EstimatedPayout
|
||||
sheet.range('D15').value = BookingAmount
|
||||
sheet.range('D16').value = FullPayment
|
||||
Reference in New Issue
Block a user