jmausolf / poshmark_sharing

BSD 3-Clause "New" or "Revised" License
111 stars 58 forks source link

Timing #25

Open LexiFramness opened 4 years ago

LexiFramness commented 4 years ago

Is there a way to edit the time between each item in the closet is being shared? I believe the timing referenced in the readme is in regards to the entire script running again. I would love to be able to have items in my closet shared every 3-5 seconds.

jmausolf commented 4 years ago

So yes, there is not a command-line option to edit the timing between each item shared. The function that shares each item is called clicks_share_followers, which has a default argument d=4.5, where 4.5 is the delay time in seconds. This value is input into the function rt which generates 1000 random times around the base value, in this case, 4.5 seconds. So you might get values of about 3-6 seconds. Original code:

def clicks_share_followers(share_icon, d=4.5):

    ## First share click
    driver.execute_script("arguments[0].click();", share_icon); time.sleep(rt(d))

    ## Second share click
    share_pat = "//a[@class='pm-followers-share-link grey']"
    share_followers = driver.find_element_by_xpath(share_pat)
    driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(d))

Now the function, clicks_share_followers has two random delays built-in. One after clicking the share icon and another after clicking the share to my followers icon in the pop-up. To adjust the times, you could change the default value of 4.5 to a different time in the code (line 178) or change each line to a different value of your choice. After you save your changes to the code, you would just run the code per the instructions in the README.

Example 1: Change the Default Value

def clicks_share_followers(share_icon, d=2.5):

    ## First share click
    driver.execute_script("arguments[0].click();", share_icon); time.sleep(rt(d))

    ## Second share click
    share_pat = "//a[@class='pm-followers-share-link grey']"
    share_followers = driver.find_element_by_xpath(share_pat)
    driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(d))

Example 2: Use a different value for each step:

def clicks_share_followers(share_icon, d=4.5):

    ## First share click
    driver.execute_script("arguments[0].click();", share_icon); time.sleep(rt(2.0))

    ## Second share click
    share_pat = "//a[@class='pm-followers-share-link grey']"
    share_followers = driver.find_element_by_xpath(share_pat)
    driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(3.5))