使用硒和python发布到Facebook墙 [英] post to facebook wall using selenium and python

查看:99
本文介绍了使用硒和python发布到Facebook墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在windows 7上使用firefox 18.0和selenium webdriver与python(2.7)绑定。使用所有这一切,我已经能够登录到Facebook,转到用户的页面,发送文本到墙上的字段。但是当我让它点击发布,它不发布。我已经观察到,当我把钥匙发送到墙上的字段时,文本显示为褪色,但是当我手动输入字段时,文本看起来很暗。这可能是问题。我开始这样做,看是否可以完成...没有真正的目的..但现在它不起作用,它驱使我疯狂。任何想法?

I am using firefox 18.0 and selenium webdriver with python(2.7) bindings on windows 7. Using all this I have been able to log in to facebook, go to an user's page , send text to the wall post field. but when i make it click post, it doesn't post. I have observed that when I send the keys to the wall post field, the text appears faded, but when i manually type into the field, the text appears dark. This might be the problem. I started doing this to see if it could be done...for no real purpose.. but now that it doesn't work, its driving me crazy. Any ideas?

    driver = self.driver
    driver.get("https://www.facebook.com/")
    driver.find_element_by_id("email").clear()
    driver.find_element_by_id("email").send_keys("mailid@email.com")
    driver.find_element_by_id("pass").clear()
    driver.find_element_by_id("pass").send_keys("password")
    driver.find_element_by_id("u_0_4").click()

    #i wanted to post multiple times.. but it doesn't work even once
    for i in range(1,11):
        driver.get("https://www.facebook.com/<username>")
        el=driver.find_element_by_id("u_0_1r")#post field
        el.clear()
        print i
        el.click()
        el.clear()
        el.send_keys(Keys.RETURN)
        time.sleep(1)
        el.click()
        #assume fwords is a list of words
        el.send_keys('test output: '+random.choice(fwords))
        el.click()
        el.click()
        time.sleep(2)
        driver.find_element_by_id("u_0_1m").click()
        driver.find_element_by_xpath("//form[@id='u_0_1l']/div/div[4]/div/ul/li[2]/label/input").click()
        time.sleep(8)


推荐答案

它适用于硒驱动程序。

这篇关于使用硒和python发布到Facebook墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆