如何使用Selenium标记帖子标题中的Facebook页面?

时间:2017-01-26 18:47:27

标签: python selenium selenium-webdriver automated-tests selenium-chromedriver

我正在尝试编写一个脚本,自动将Facebook帖子分享到不同的Facebook群组(列表中)。 所以,我想通过脚本本身标记标题中的其他页面

注意:我已经尝试过' ARROW_DOWN'并单击特定于登录用户喜欢的建议页面。这种方式对我不起作用,因为这个脚本需要被不同的用户使用(他们喜欢不同的页面,所以他们有不同的标签建议Click to see how pages are tagged usually

P.S。:只为每个用户避免自定义脚本。

这里有一些来自脚本的代码,用户通过CLI输入字幕作为字符串变量" caption_text" :

    for i in groups:
        try:
            self.driver.get(str(i))
            actions = ActionChains(self.driver)
            time.sleep(2)
            actions.send_keys('p').perform()
            time.sleep(1)

            actions2 = ActionChains(self.driver)
            actions2.send_keys(str(post_url) + " ").perform()
            time.sleep(3)


            actions4 = ActionChains(self.driver)

            for j in range(0, 15):
                actions4.send_keys(Keys.BACK_SPACE).perform()

            caption = ActionChains(self.driver)
            caption.send_keys(caption_text).perform()

            click_post = self.driver.find_element_by_class_name("_332r")
            click_post.click()
            time.sleep(10)
            print "Successfully posted in " + str(i.split('https://www.facebook.com/groups/')[1].split('/')[0])
        except:
            print"Error posting in " + str(i.split('https://www.facebook.com/groups/')[1].split('/')[0])

希望有人可以帮忙! 谢谢:))

0 个答案:

没有答案