Code Monkey home page Code Monkey logo

Comments (2)

wkaisertexas avatar wkaisertexas commented on June 2, 2024 1

Hey, so the biggest hack that I would use to get around this is adding an extra space after the @IceSpicee simply because I think the code that I wrote to perform the action chains to go through the upload process breaks down if there is not that there.

 try:
        while description:
            nearest_mention = description.find('@')
            nearest_hash = description.find('#')

            if nearest_mention == 0 or nearest_hash == 0:
                desc.send_keys('@' if nearest_mention == 0 else '#')

                # wait for the frames to load
                time.sleep(config['implicit_wait'])

                name = description[1:].split(' ')[0]
                if nearest_mention == 0: # @ case
                    mention_xpath = config['selectors']['upload']['mention_box']
                    condition = EC.presence_of_element_located((By.XPATH, mention_xpath))
                    mention_box = WebDriverWait(driver, config['explicit_wait']).until(condition)
                    mention_box.send_keys(name)
                else:
                    desc.send_keys(name)

                time.sleep(config['implicit_wait'])

                if nearest_mention == 0: # @ case
                    mention_xpath = config['selectors']['upload']['mentions'].format('@' + name)
                    condition = EC.presence_of_element_located((By.XPATH, mention_xpath))
                else:
                    hashtag_xpath = config['selectors']['upload']['hashtags'].format(name)
                    condition = EC.presence_of_element_located((By.XPATH, hashtag_xpath))

                elem = WebDriverWait(driver, config['explicit_wait']).until(condition)

                ActionChains(driver).move_to_element(elem).click(elem).perform()

                description = description[len(name) + 2:] # this is the code which I think has the problem
            else:
                min_index = _get_splice_index(nearest_mention, nearest_hash, description)

                desc.send_keys(description[:min_index])
                description = description[min_index:]
    except Exception as exception:
        print('Failed to set description: ', exception)
        _clear(desc)
        desc.send_keys(saved_description) # if fail, use saved description

I am really sorry for writing code like this, very confusing as I tried too hard to not repeat myself I think.

from tiktok-uploader.

nhantamz avatar nhantamz commented on June 2, 2024

Hi bro, thank u for your response.

I have tested on windows (same as your demo, no modification) and it i was ok. So I think this issue only occurs on Linux (I tested in headless Chrome only, even I added extra space at end of description).

BTW, on headless chrome Linux, almost every try it will give error like that:

image

it can't access the upload page.

my server is Ubuntu 20: 4 vCores 8G RAM, it have ip v4 and v6, Chrome 114 latest.

PS: If i use headless param on your function it will show error:

image

I have to add option

options.add_argument('--headless=new')
options.add_argument('--no-sandbox')

Feel free to check it

Thank you.

from tiktok-uploader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.