jmcarp / robobrowser

BSD 3-Clause "New" or "Revised" License
3.7k stars 337 forks source link

Javascript support #62

Open jschlade opened 8 years ago

jschlade commented 8 years ago

I know this question isn't specifically related to robobrowser but I'm using Joshua Carp's awesome robo browser python package. I was hoping to contact him directly but I'm not sure if that's possible on GitHub.

Anyway I'm looking for a pure python 3 headless JavaScript browser package and I can't seem to find any. I've looked and looked and all the ones that I've researched have underlying dependencies which makes them less appealing.

I'm relatively new to python, and I'm using python 3.x. Some of my code may run on a NAS server that has a python 3.5 distribution but uses it's own proprietary 64-bit Linux. (specifically a Synology 716+ NAS) or as a standalone application.

I really want to use something that's self contained, isn't doing any RPC based controlling of a headless browser either, etc.

I can't find anything and I'm thinking nothing exists. Do anyone know of one?

Thanks

jmcomets commented 8 years ago

You should take look at Selenium with PhantomJS.

from selenium import webdriver
driver = webdriver.PhantomJS()
driver.set_window_size(800, 600)
driver.get("https://duckduckgo.com/")
driver.find_element_by_id('search_form_input_homepage').send_keys("rick astley")
driver.find_element_by_id("search_button_homepage").click()
print(driver.current_url)
driver.quit()