zoukankan      html  css  js  c++  java
  • selenium实战脚本集——新浪微博发送QQ每日焦点(火狐)

    selenium实战脚本集(1)——新浪微博发送QQ每日焦点,乙醇用谷歌实现的,下边是用火狐实现的。

    代码如下:

    # coding = utf-8
    from selenium import webdriver
    import time
    
    profiles = 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.text
    url = today.get_attribute("href")
    print content.encode("utf-8")
    print url
    
    driver.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()

    常见错误

    xp和win7下面chrome 的profile路径是不一样的

    • Windows XP:%userprofile%Local SettingsApplication DataMozillaFirefoxProfiles或%userprofile%Application DataMozillaFirefoxProfiles
    • Windows Vista/Windows 7/Windows 8:%localappdata%MozillaFirefoxProfiles
  • 相关阅读:
    servlet
    过滤器
    拦截器
    logback
    hibernate(1)
    函数的关键字参数
    函数的不定长参数
    打印星形三角
    九九乘法表
    udp客户端收发数据流程
  • 原文地址:https://www.cnblogs.com/xmlbw/p/4422751.html
Copyright © 2011-2022 走看看