#๐Ÿ”’ automating submitting a form

10 messages ยท Page 1 of 1 (latest)

undone belfryBOT
#

@tall plume

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tall plume
#
    form_data['submission_title_1'] = story_title
    form_data['submission_description_2'] = story_description[:250]
    form_data['short_story_3'] = story_itself
    form_data['acknowledgement_4'] = 'on'
    form_data['submt-btn'] = 'submit'

    print("\nForm Data being submitted:")
    print(json.dumps(form_data, indent=4, ensure_ascii=False))

    # 8. Introduce a delay (TEMPORARILY REMOVED FOR DEBUGGING)
    # time.sleep(random.randint(3, 7))

    # 9. Submit the form
    print(f"\n--- Submitting Story Form: {story_form_url} ---")
    print(f"Submission POST Request Headers: {submit_response.request.headers if 'submit_response' in locals() else headers}")
    print(f"Submission POST Request Data: {submit_response.request.body.decode('utf-8') if 'submit_response' in locals() and submit_response.request.body else form_data}")
    submit_response = session.post(story_form_url, data=form_data, headers=headers, allow_redirects=True) # Ensure allow_redirects is True
    submit_response.raise_for_status()
    print(f"Story Submission Status Code: {submit_response.status_code}")
    print(f"Final URL after submission: {submit_response.url}")
    print("\nResponse Headers after Submission:")
    print(submit_response.headers)
    print("\nFull Response Content of the submission:")
    print(submit_response.text)  # Print the ENTIRE content

    # 10. Check if redirected to the thank you page
    if submit_response.url == thank_you_url:
        print("\nSuccess! Successfully submitted the story and redirected to the thank you page.")
    else:
        print("\nSubmission might have failed or redirection to the thank you page did not occur.")

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")
except requests.exceptions.HTTPError as e:
    print(f"HTTP Error: {e}")```
#

here is the code

#

im pretty sure this is the part where it submits and at the end it checks if its in the thank you page

tall plume
#

ok nvm i think i found out ill use selenium

#

how to close the thread

undone belfryBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.