Filesystem

Read, write, upload and download files in your Scrapybara instance

1

Start an instance

1from scrapybara import Scrapybara
2
3client = Scrapybara(api_key="your_api_key")
4instance = client.start(instance_type="small")
2

Write a file

1# Write content to a file
2instance.file.write(
3 path="/path/to/file.txt",
4 content="Hello from Scrapybara!",
5 encoding="utf-8" # Optional: specify encoding
6)
3

Read a file

1# Read file content
2response = instance.file.read(
3 path="/path/to/file.txt",
4 encoding="utf-8" # Optional: specify encoding
5)
6content = response.content
4

Upload a file

1# Upload a file to the instance
2instance.file.upload(
3 path="/destination/path/file.txt",
4 content="file_content_as_string"
5)
5

Download a file

1# Download a file from the instance
2response = instance.file.download(
3 path="/path/to/file.txt"
4)
5downloaded_content = response.content
Was this page helpful?
Built with