jmausolf / poshmark_sharing

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

0 Items in Closet #27

Open asanab76 opened 4 years ago

asanab76 commented 4 years ago

After successful login, when the share war scrolls through the closet it is not returning any items. I believe Posh may have changed the CSS selectors that are being referenced in the program. For testing I deleted and re-cloned the repo to ensure that this was not an issue with my current install.

`[*] scrolling through all items in closet...

[*] sharing PoshMark listings for 0 items in closet... please wait... `

akabeera commented 4 years ago

Ran into this myself. I had to update the get_closet_share_icons() function with the following code:

item_pat = "//div[@class='d--fl ai--c social-action-bar__action social-action-bar__share']"
items = driver.find_elements_by_xpath(item_pat)
share_icons = [i.find_element_by_css_selector("a[class='share']") for i in items]

However sometimes I noticed the old way works as well. Posh randomly loads either the new way or the old way so it makes sense to test for both

monbon23 commented 4 years ago

I've tried both ways - the new one from @akabeera and the old one. unable to get it to share my closet. It scrolls through fine, but keeps returning 0 items

bennettl commented 4 years ago

Same issue, code snippet doesn't work for me either

lakahn commented 4 years ago

Has this issue been resolved? I have also tried code snippet to no avail.

selahlion commented 4 years ago

Edit the CSS Selectors to the updated version currently on the poshmark website and it works perfectly again

On Tue, Jul 21, 2020 at 9:21 PM Bennett Lee notifications@github.com wrote:

Same issue, code snippet doesn't work for me either

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jmausolf/poshmark_sharing/issues/27#issuecomment-662187493, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKWTSUYRQXA2G65VXCOCYLR4Y5KRANCNFSM4MZX6N5Q .

lakahn commented 4 years ago

@selahlion could you please show me what the code would look like for this? I can't seem to find the correct selectors that will make this work, including the ones suggested above. (I'm brand-spaking-new to self-teaching myself CS and I'm struggling a bit here...) Many many thanks!

branrodgers commented 4 years ago

<div data-et-name="share" data-et-element-type="button" data-et-prop-listing_id="product id" class="d--fl ai--c social-action-bar__action social-action-bar__share"><i class="icon share-gray-large"></i><!----></div>

Based upon the code, what do you change in... share_icons = [i.find_element_by_css_selector("a[class='share']") for i in items]

Do you change it to... share_icons = [i.find_element_by_css_selector("a[data-et-name='share']") for i in items]

krislindgren commented 4 years ago

The following code now works for me:

def get_closet_share_icons():

    item_pat = "//div[@class='d--fl ai--c social-action-bar__action social-action-bar__share']"
    items = driver.find_elements_by_xpath(item_pat)
    share_icons = [i.find_element_by_css_selector(".share-gray-large") for i in items]
    return share_icons

def clicks_share_followers(share_icon, d=2):

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

    ## Second share click
    share_pat = "//a[@class='internal-share__link']"
    share_followers = driver.find_element_by_xpath(share_pat)
    driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(d))
krislindgren commented 4 years ago

I also put up a pull request with the fix for this: https://github.com/jmausolf/poshmark_sharing/pull/28

rafiks commented 4 years ago

does it share all of the available items? it seems when I ran it only ran a portion. -- it seems i forgot that I changed the N parameter. :)

branrodgers commented 4 years ago

I found that after the updated software, the code wasn't sharing all of the closest. I wasn't sure if this was my device being old/slow or if I'm having network issues. I found the program wasn't scrolling all the way to the bottom like it should regardless of how many N I put in; some type of delay. So I added a line to have the scroll funtion wait 5 seconds between scrolls to load the whole page. Again, this could be a result of my old hardware or a network issue I'm having.

rafiks commented 4 years ago

I found that after the updated software, the code wasn't sharing all of the closest. I wasn't sure if this was my device being old/slow or if I'm having network issues. I found the program wasn't scrolling all the way to the bottom like it should regardless of how many N I put in; some type of delay. So I added a line to have the scroll funtion wait 5 seconds between scrolls to load the whole page. Again, this could be a result of my old hardware or a network issue I'm having.

I tested with a delay of 5 and it still only sharing 48..

krislindgren commented 4 years ago

I dont have this issue? Mine finds and shares the entire closet. Is it only detecting 48 items? or is it specifically only sharing 48 items?

lakahn commented 4 years ago

@rafiks that happens randomly to me, I've found. Usually it just happens if something interrupts it from scrolling. Usually if you just restart terminal and re-run the command until it completely scrolls to the bottom of my closet. Ways I avoid this happening as frequently are ensuring the testing window is at the forefront of my screen, and I don't move the mouse/click elsewhere while it is scrolling. Not an issue with the code.

rafiks commented 4 years ago

i grabbed a fresh copy of the code and it seems to be working now.

jordanaroth commented 4 years ago

I also put up a pull request with the fix for this: #28

I took the .py from your pull request and I get:

[] scrolling through all items in closet... [] ERROR in Share War

branrodgers commented 4 years ago

Is anyone else experiencing where everything is working correctly but at some point durning the share process, the code breaks and shows ERROR in Share War?

I've tested on two different machine with the same code and so far it will begin sharing the items but at some point in the share process it stops and returns the error on each machine. I can't for the life of me think what this error might be. Maybe the selenium driver is crashing? I have quite a few items in my closest that I share(if that makes a difference).

bennettl commented 4 years ago

Code now starts sharing without fully scrolling through closet, seems to happen when it takes a while to load the next section

lakahn commented 4 years ago

aaaaand it looks like they've updated the site again. Anyone got a fix? I can't figure out these selectors to save my life...

branrodgers commented 4 years ago

I modified what/how to search for the items by changing the code to

def get_closet_share_icons():

    item_pat = 'a.share'
    items = driver.find_elements_by_css_selector(item_pat)
    return items

Then

def clicks_share_followers(share_icon, d=2):

    ## 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))

The second click argument could be written as share_pat = 'a.pm-followers-share-link grey' share_followers = driver.find_element_by_css_selector(share_pat)

rafiks commented 4 years ago

went back to the original code and it seems to be working.

jordanaroth commented 4 years ago

@branrodgers code fix was working for about a week, now it's broken again :(

branrodgers commented 4 years ago

Wrote as this.

def get_closet_share_icons():
    item_pat = 'div[class*="share"]'
    items = driver.find_elements_by_css_selector(item_pat)
    return items
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='internal-share__link']"
    share_followers = driver.find_element_by_xpath(share_pat)
    driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(d))

The code isn't copy and pasting right. Just watch the spacing.

gradyrobbins commented 4 years ago

Legend @branrodgers thank you!

kzoran commented 4 years ago

Wrote as this.

def get_closet_share_icons():
    item_pat = 'div[class*="share"]'
    items = driver.find_elements_by_css_selector(item_pat)
    return items
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='internal-share__link']"
    share_followers = driver.find_element_by_xpath(share_pat)
    driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(d))

The code isn't copy and pasting right. Just watch the spacing.

This is working for me as well. Thank you!

orginaldotbuilders commented 4 years ago

The following code now works for me:

def get_closet_share_icons():

    item_pat = "//div[@class='d--fl ai--c social-action-bar__action social-action-bar__share']"
    items = driver.find_elements_by_xpath(item_pat)
    share_icons = [i.find_element_by_css_selector(".share-gray-large") for i in items]
    return share_icons

def clicks_share_followers(share_icon, d=2):

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

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

This works. just update the css selectors.

JoannaTsai1218 commented 4 years ago

The following code now works for me:

def get_closet_share_icons():

    item_pat = "//div[@class='d--fl ai--c social-action-bar__action social-action-bar__share']"
    items = driver.find_elements_by_xpath(item_pat)
    share_icons = [i.find_element_by_css_selector(".share-gray-large") for i in items]
    return share_icons

def clicks_share_followers(share_icon, d=2):

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

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

This works. just update the css selectors.

This works for me!!! Thank you @orginaldotbuilders @branrodgers

QuantoC commented 4 years ago

Hi, get_closet_share_icons() doesn't work again. Does anybody have a fix for it?

Best, Christian

branrodgers commented 4 years ago

I modified what/how to search for the items by changing the code to

def get_closet_share_icons():

    item_pat = 'a.share'
    items = driver.find_elements_by_css_selector(item_pat)
    return items

Then

def clicks_share_followers(share_icon, d=2):

    ## 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))

The second click argument could be written as share_pat = 'a.pm-followers-share-link grey' share_followers = driver.find_element_by_css_selector(share_pat)

This one works after their update

QuantoC commented 4 years ago

Thanks a lot!

orginaldotbuilders commented 4 years ago

Yes @branrodgers ! awesome thank you!

cbrown83 commented 4 years ago

Seems my browser opens in old format sometimes and new other times. In order to support both old and new formats, I hacked together the following:

def get_closet_share_icons():
    item_pat = "//div[@class='social-info social-actions d-fl ai-c jc-c']"
    items = driver.find_elements_by_xpath(item_pat)
    share_icons = [i.find_element_by_css_selector("a[class='share']") for i in items]
    if not share_icons:
        item_pat = "//div[@class='d--fl ai--c social-action-bar__action social-action-bar__share']"
        items = driver.find_elements_by_xpath(item_pat)
        share_icons = [i.find_element_by_css_selector(".share-gray-large") for i in items]
    return share_icons

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
    try:
        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))
    except:
        share_pat = "//a[@class='internal-share__link']"
        share_followers = driver.find_element_by_xpath(share_pat)
        driver.execute_script("arguments[0].click();", share_followers); time.sleep(rt(d))

Not super pretty but does the trick and runs continuously (aside from the captcha thwarting).