Environment Variables
Environment Variables
NOTE
This feature is only available in the Crawlab Pro Edition.
Crawlab allows users to set environment variables during spider runtime.
Setting Environment Variables
- Navigate to the
Environment Variables
page. - Click the
Create Environment Variable
button. - Fill in the configuration form.
Accessing Environment Variables
Assuming we have set an environment variable with the key FOO
and the value BAR
, we can access it in a spider script using the following sample code.
import os
foo = os.environ.get('FOO')
print(foo) # BAR