I have this HTML code I'm proccesing/scrapping with a python script:
<a href="javascript:VerMapa('AVDA. DE AMERICA, 2 -33880 POLA DE ALLANDE','RODRIGUEZ-PELAEZ PEÑA, ANA MARIA','AVDA. DE AMERICA, 2 -33880','33880','ALLANDE','183','178')"><img src="../../Fijos/Img/VerMapa.jpg" alt="" width="25" height="24" border="0"> <br>Ver Mapa</a>
This is the definition of the function:
function VerMapa(direccion,farmacia,domicilio,CP,municipio, numeroOficina,identidad) {
window.open("googleMaps.aspDir="+direccion+"&Far="+farmacia+"&Dom="+domicilio+"&CP="+CP+"&Mun="+municipio+"&NO="+numeroOficina+"&Id="+identidad+"&",'Lista','toolbar=no, menubar=no, scrollbars=yes,resizable=yes,status=yes,screenX=50,top=50,width=740,height=530');
}
I need to make a call to VerMapa('AVDA. DE AMERICA, 2 -33880 POLA DE ALLANDE','RODRIGUEZ-PELAEZ PEÑA, ANA MARIA','AVDA. DE AMERICA, 2 -33880','33880','ALLANDE','183','178')
javascript function in the href attribute and get the HTML code returned.
I have checked spider-monkey and PyV8 but I think they can't help me here. spider-monkey is clear telling you can´t call a javascript defined function.
I'm now trying with Selenium, but I don't know how I can get the source code back to python.
By know I just have implemented a test script and managed to load the requested page in a browser window.
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.farmasturias.org/GESCOF/cms/Guardias/FarmaciaBuscar.asp?IdMenu=111")
htmlCode = browser.execute_script("return VerMapa('AVDA. DE AMERICA, 2 -33880 POLA DE ALLANDE','RODRIGUEZ-PELAEZ PEÑA, ANA MARIA','AVDA. DE AMERICA, 2 -33880','33880','ALLANDE','183','178')")
print htmlCode;
1.- I am not getting anything in htmlCode var. ¿How can I get back the source code generated by the javascript function? I have taken the syntax from this post Getting the return value of Javascript code in Selenium
2.- Is there any way to use Selenium without opening any browser window?