Take Baidu map as an example to query the bus route between two addresses and use the python driverSelenium RC.
Prerequisites:
Http://seleniumhq.org/docs/05_selenium_rc.html#learning-the-api-Selenium RCStructure,Install sdks in various languages
Http://seleniumhq.org/docs/->Selenium ideUsage
Step 1: Use selenium ide To produce PythonCode
Base URL:
Http://map.baidu.com/ide only records the actions that are generated in the domain name specified by the base URL
Source:
The following code fills in selenium IDE in the order of commnd targe Value
Open/
Open current page
Click tab2
Click bus button
Type bussearchsta Intersection
Enter site
Type bussearachend Intersection
Enter site
Click // form [@ ID = 'form2']/Div [2]/input [1]
Click Baidu
Waitforelementpresent // P [@ ID = 'blinfo _ 0']
Waiting for Data
Step 2: Export Python
Select export as Python to obtain the Python code.
Step 3: Obtain HTML data in Python
Searchresult = self. Selenium. get_eval ("this.browserbot.getcurrentwindow().doc ument. getelementbyid ('route _ list'). innerhtml ")