Selenium actual Combat script set (1)-Sina Weibo to send QQ daily focus, ethanol with Google implementation, the bottom is implemented with Firefox.
The code is as follows:
#coding = Utf-8 fromSeleniumImportWebdriverImportTimeprofiles= Webdriver. Firefoxprofile ("c:/documents and Settings/administrator/application data/mozilla/firefox/profiles/rhw9fq7m.default") Driver=Webdriver. Firefox (Profiles) Driver.get ("http://www.qq.com") Today= Driver.find_element_by_css_selector ("#todaytop a") Content=Today.texturl= Today.get_attribute ("href")PrintContent.encode ("Utf-8")PrintUrldriver.get ("http://www.weibo.com") Time.sleep (5) Driver.find_element_by_css_selector ("textarea. W_input"). Send_keys (content+URL) driver.find_element_by_css_selector ("a.w_btn_a.btn_30px"). Click () time.sleep (5) Driver.close ()
Common errors
XP and Win7 below Chrome's profile path is not the same
- Windows xp:%userprofile%\local Settings\Application Data\mozilla\firefox\profiles\ or%USERPROFILE%\Application Data\ Mozilla\firefox\profiles\
- Windows vista/windows 7/windows 8:%localappdata%\mozilla\firefox\profiles\
Selenium real-day script set-Sina Weibo sends QQ Daily Focus (Firefox)