To upload files, we provide the click_and_upload function, which takes in an element description and a file to upload. The element description must be an element that would normally open the operating system file upload dialog.We’re using a file called “logo.png” in this example.
upload_file.py
Copy
Ask AI
from simplex import Simpleximport ossimplex = Simplex(api_key="your_api_key") # no need for proxies in this example -- Simplex doesn't block our automation.simplex.create_session(proxies=False)simplex.goto("https://simplex.sh/upload-example.html")simplex.click_and_upload("Click or drag and drop an image", "logo.png")print(simplex.extract_text("File name"))
To download files, we provide the click_and_download function, which takes in an element description. The element description must be an element that starts a file download.We return the filename and the bytes of the file so you can either write it to disk or pass it to a cloud storage (S3, GCS, etc).
download_file.py
Copy
Ask AI
from simplex import Simpleximport ossimplex = Simplex(api_key="your_api_key")simplex.create_session(proxies=False)simplex.goto("https://simplex.sh/download-example.html")simplex.click("Select action")filename, content_bytes = simplex.click_and_download("Download logo")print(filename)print(len(content_bytes))with open(filename, 'wb') as f: f.write(content_bytes)