• 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
  • 相关阅读:
    FR #3题解
    L3-005. 垃圾箱分布
    L2-004. 这是二叉搜索树吗?
    L2-002. 链表去重
    L1-009. N个数求和
    L3-003. 社交集群
    L3-004. 肿瘤诊断
    L2-001. 紧急救援
    L3-002. 堆栈
    L2-007. 家庭房产
  • 原文地址:https://www.cnblogs.com/xmlbw/p/4422751.html
Copyright © 2020-2023  润新知