Home > Article > Backend Development > Use Selenium to simulate login and obtain page content
Traditional cURL cannot execute browser scripts in the page, and when crawling some web pages that have restrictions on crawlers, it is often necessary to set detailed http headers to break through the restrictions, which is more complicated to write. Introduction to Selenium:Selenium is a tool for web application testing (and not just for testing). Selenium IDE: Firefox plug-in, with the function of recording scripts. Supports automatic recording of actions and automatic generation of automation scripts in other languages. Selenium Remote Control (RC): supports multiple platforms (Windows, Linux) and multiple browsers (IE, Firefox, Opera, Safari, Chrome), and can be used in multiple languages (Java, Ruby, Python, Perl, PHP, C# )Write use cases. Selenium Grid: Allows Selenium-RC to scale for large test case sets or test case sets that need to be run in different environments. Example: Drive chrome to simulate logging into Taobao and obtain page information 1. Go to the project homepage: SeleniumHQ download Selenium Server (formerly the Selenium RC Server) Third Party Browser Drivers NOT DEVELOPED by seleniumhq (Select chrome driver) Third Party Language Bindings NOT DEVELOPED by seleniumhq(Choose PHP by Adam Goucher (SeHQ recommended php client)) 2.Open selenium
If you need to run for a long time, please set the timeout period in each '[ ]' as appropriate 3.php code
After that, you can perform various operations of the element method on the $session instance as needed. Supports the following methods to select elements ID xpath link text partial link text name tag name class name css selectorPS: How various libraries detect Ajax situations jQuery: "jQuery.active" Prototype: "Ajax.activeRequestCount" Dojo: "dojo.io.XMLHTTPTransport.inFlight.length" |