简体   繁体   English

Facebook-获取python函数重复吗?

[英]Facebook - Getting a python function to repeat?

I am hoping someone may be able to point out the error I am making; 我希望有人可以指出我所犯的错误; it is probably very straight forward! 这可能非常简单! What I am trying to do is run some code previous what I have shown below, then when I get to this point I need to get it to hold for the 600 seconds and then reload the download page: 我想做的是在下面显示的代码之前运行一些代码,然后到这一点,我需要将其保留600秒,然后重新加载下载页面:

try:
    # Clicks OK in Download Requested window
    driver.implicitly_wait(10)
    ClickOkay = driver.find_element_by_css_selector("._42ft._42fu.layerCancel.uiOverlayButton.selected._42g-._42gy")
    ClickOkay.click()
except:
    print("error 2")
   # Wait Time
   # time.sleep(600)  # Allow Facebook to compile the archive

    # Reload Settings page
    GoToURL('https://www.facebook.com/' + 'settings', driver)

    # Goes back through to Download page
    link = driver.find_element_by_link_text('Download a copy')
    link.click()

At this point if the archive has finished being created then the button changes from Start Archive to Download Archive. 此时,如果完成了存档的创建,则按钮将从“开始存档”更改为“下载存档”。 However depending on the size of the profile the time taken to compile the archive varies. 但是,根据配置文件的大小,编译归档文件所花费的时间会有所不同。 so what i was attempting (with the code below and a couple of attempts with the if and while arguments) was to get it to check if the button exists and if not go back and wait 300 seconds before trying again. 所以我正在尝试(使用下面的代码以及使用if和while参数进行几次尝试)是让它检查按钮是否存在,如果不存在,请返回并等待300秒再尝试。 Once the button appears it will then continue on to download using additional code. 按钮出现后,它将继续使用其他代码进行下载。

    try:
        print("Checking if button exists")
        DownloadArchive = driver.find_elements_by_css_selector("._42ft._42fu.selected._42gz._42gy")
        print(DownloadArchive.count())

        if(DownloadArchive.count() > 0):
            print("button exists")
        else:
            print("button does not exist")
        # Button to initiate password entry popup window
        #driver.implicitly_wait(10)
        #while (DownloadArchive = driver.find_element_by_css_selector("._42ft._42fu.selected._42gz._42gy")):
        #    if (DownloadArchive = True):
        #        DownloadArchive.click()
        #        print("wait")
        #    else:time.sleep(300)

Thanks in advance, James 预先感谢,詹姆斯

You're mixing the assignment operator ( = ) with the equal operator ( == ). 您正在将赋值运算符( = )与相等运算符( == )混合在一起。

So it should be: 因此应该是:

while (DownloadArchive == driver.find_element_by_css_selector("._42ft._42fu.selected._42gz._42gy")):
    if (DownloadArchive == True):

Or just: 要不就:

while DownloadArchive == driver.find_element_by_css_selector("._42ft._42fu.selected._42gz._42gy"):

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM