Professional Documents
Culture Documents
chrome_options = Options()
#chrome_options.add_argument("--kiosk") #poner pantalle en grande
driver = webdriver.Chrome(chrome_options=chrome_options)
#excel = openpyxl.load_workbook(r'C:\Users\juan.camacho\Desktop\DATOS\
Sellers\.xlsx') 16069
#ruta = r'C:\Users\juan.camacho\Documents\python\venue\venue.xlsx'
driver.get('https://www.google.com/maps/@10.97728,-74.8126208,13z?hl=es')
window_before = driver.window_handles[0]
print("headless")
driver.implicitly_wait(1)
lista=[]
lista2=[]
fil=1
colun=1
colu=1
bus=0
d=10000#int(input("ingresar numero de fila")) 18217
#15958
n=5
b=8
a=11
contexcel=0
my_wb = openpyxl.Workbook()
my_sheet = my_wb.active
contador=0
def excel(d):
excell = openpyxl.load_workbook(r'C:\Users\juan.camacho\Documents\python\venue\
uscities.xlsx')
sheet = excell.get_sheet_by_name('Sheet1')
num=str(d)
#print (sheet['A'+num].value)
code= sheet['A'+num].value
code2= sheet['D'+num].value
return(code,code2)
while True:
#time.sleep(0.2)
searh=
driver.find_element("xpath","""//*[@id="searchboxinput"]""").send_keys(palabra)
#time.sleep(0.2)#HOLAAA
clic= driver.find_element("xpath","""//*[@id="searchbox-
searchbutton"]""").click()
time.sleep(1)
#fil,colun,colu=busca(fil,colun,colu)
n=5
b=8
#HOLAAAAAAAAA
while True:
n=n+2
b=b+2
ib=b
contador=contador+1
if contador>30410:
n=5
b=8
lista=[]
if d>30410:
#print("siguiente")
my_wb.close()
contexcel=contexcel+1
original = r'C:\Users\juan.camacho\Documents\python\venue\
venue.xlsx'
target = r'C:\Users\juan.camacho\Documents\python\venue\
venue'+str(contexcel)+'.xlsx'
shutil.copyfile(original, target)
bus=bus+1
d=0
searh=
driver.find_element("xpath","""//*[@id="searchboxinput"]""").clear()
#time.sleep(0.2)
clic= driver.find_element("xpath","""//*[@id="searchbox-
searchbutton"]""").click()
time.sleep(1)
contador=0
break
try:
click2=driver.find_element("xpath","""//*[@id="QA0Szd"]/div/div/div[1]/div[2]/div/
div[1]/div/div/div[2]/div[1]/div["""+str(b)+"""]""").click()
time.sleep(0.1)
click_rest=driver.find_element("xpath","""//*[@id="QA0Szd"]/div/div/
div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]/div["""+str(n)+"""]/div/
a""").click()
#print(n)
time.sleep(0.3)
except:
#n=n+2
try:
#searh=
driver.find_element("xpath","""//*[@id="searchboxinput"]""").clear()
#time.sleep(0.2)
#clic= driver.find_element("xpath","""//*[@id="searchbox-
searchbutton"]""").click()
driver.get('https://www.google.com/maps/@10.97728,-74.8126208,13z?
hl=es')
#n=5
#print("error break")
break
except:
#print("break")
break
break
#time.sleep(0.2)
#print("hola")
print(name.text)
#for e in name:
#print(e.text)
#lista2.append(e.text)
#c1 = my_sheet.cell(row = fil, column = colun)
#c1.value = e.text
#time.sleep(0.2)
except:
#print("continue")
continue
#try:
#driver.find_element("xpath","""//*[@id="QA0Szd"]/div/div/div[1]/div[3]/div/
div[1]/div/div/div[2]/div["""+str(a)+"]").click()
#a=12
#except:
#print("error4")
#a=a+1
#pass
contlist=0
phone=driver.find_elements(By.CLASS_NAME, "rogA2c")
try:
for i in phone:
colu=colu+1
#print(i.text)
#lista.append(i.text)
#print(lista)
c4 = my_sheet.cell(row = fil, column = 13)
c4.value = code2 #[contlist]
c3 = my_sheet.cell(row = fil, column = 12)
c3.value = code #[contlist]
c2 = my_sheet.cell(row = fil, column = colu)
c2.value = i.text #[contlist]
c0 = my_sheet.cell(row = fil, column = 11)
c0.value = Busqueda[bus]
c1 = my_sheet.cell(row = fil, column = colun)
c1.value = name2
except:
continue
#print(lista[contlist])
#contlist=contlist+1
print("holaaa")
fil=fil+1
colu=1
my_wb.save(r'C:\Users\juan.camacho\Documents\python\venue\venue.xlsx')
#time.sleep(0.2)
try:
time.sleep(0.2)
click2=driver.find_element("xpath","""//*[@id="QA0Szd"]/div/div/div[1]/div[2]/div/
div[1]/div/div/div[2]/div[1]/div["""+str(b)+"""]""").click()
#b=b+2
#print("final")
except:
#b=b-2
print("ERROR EN B")
try:
time.sleep(0.2)
click_rest=driver.find_element("xpath","""//*[@id="QA0Szd"]/div/div/div[1]/div[2]/
div/div[1]/div/div/div[2]/div[1]/div["""+str(n)+"""]/div/a""").click()
except:
#n=n+2
driver.get('https://www.google.com/maps/@10.97728,-74.8126208,13z?
hl=es')
#atras1=driver.find_element("xpath","""//*[@id="QA0Szd"]/div/div/div[1]/div[2]/
div/div[1]/div/div/div[1]/button[1]/div/img""").click()
#atras2=driver.find_element("xpath","""//*[@id="omnibox-
singlebox"]/div[1]/div[1]/button/img""").click()
#time.sleep(0.2)
searh=
driver.find_element("xpath","""//*[@id="searchboxinput"]""").send_keys(palabra)
#time.sleep(0.2)
clic= driver.find_element("xpath","""//*[@id="searchbox-
searchbutton"]""").click()
time.sleep(1)
print("error1")
pass
continue
my_wb.close()