Selenium, as a tool for testing Web applications.
1, configure the path and browser of selenium, I use Firefox
webdriver.firefox.bin=d:/tools/firefox/firefox.exewebdriver.gecko.driver=d:/project/geckodriver.exe
selenium.properties
respectively, the installation path of Firefox and the driving path of Firefox, the main driver is to drive Firefox auto-Open, click the button and other operations.
2,
Public classselenium{Private StaticString Driver = ""; Private StaticString FireFox = ""; Static { //read configuration file about selenium configurationProperties Properties =NewProperties (); InputStream in= Object.class. getResourceAsStream ("/selenium.properties"); Try{properties.load (in); //Drive PathDriver = Properties.getproperty ("Webdriver.gecko.driver"); //Browser PathFireFox = Properties.getproperty ("Webdriver.firefox.bin"); } Catch(Exception e) {e.printstacktrace (); } finally { Try{in.close (); } Catch(IOException e) {e.printstacktrace (); }}} webdriver Webdriverpc=NewFirefoxdriver ();
Public Static voidMain (string[] args) {String content= Webdriverpc.get ("http://www.baidu.com")}}
This allows you to get the HTML after the request, using the
Jsoup processing
Document doc = jsoup.parse (content);
Can get inside the content.
Java crawls data through selenium automation