2020- ** Zone Management** : Automatic zone creation and management
2121- ** Multiple Output Formats** : JSON, raw HTML, markdown, and more
2222
23- ## Installation from package
23+ ## Installation
2424
25- ``` python
25+ ### From pypi
26+ ``` bash
2627# Enter your project's folder in your terminal
2728pip install brightdata
2829
2930# Make sure that you have pip installed on your device
3031```
3132
32- ## Installation from GitHub
33-
34- ``` python
33+ ### From GitHub
34+ ``` bash
3535# Clone the repository
3636git clone https://github.com/brightdata/bright-data-sdk-python.git
3737cd bright-temp
@@ -102,18 +102,7 @@ results = client.search(
102102``` python
103103# Download scraped content
104104data = client.scrape(" https://example.com" )
105- filepath = client.download_content(data, " results.json" , " json" )
106-
107- # Auto-generate filename with timestamp
108- filepath = client.download_content(data, format = " json" )
109- ```
110-
111- ### 5. Manage Zones
112-
113- ``` python
114- # List all active zones
115- zones = client.list_zones()
116- print (f " Found { len (zones)} zones " )
105+ client.download_content(data, " results.json" , " json" ) # Auto-generate filename if not specified
117106```
118107
119108## Configuration
@@ -125,7 +114,6 @@ Create a `.env` file in your project root:
125114``` env
126115BRIGHTDATA_API_TOKEN=your_bright_data_api_token
127116WEB_UNLOCKER_ZONE=your_web_unlocker_zone # Optional
128- BROWSER_ZONE=your_browser_zone # Optional
129117SERP_ZONE=your_serp_zone # Optional
130118```
131119
@@ -136,31 +124,33 @@ client = bdclient(
136124 api_token = " your_token" ,
137125 auto_create_zones = True , # Automatically create missing zones
138126 web_unlocker_zone = " custom_zone" , # Custom zone name
139- browser_zone = " custom_browser" # Custom browser zone
140127)
141128```
129+ ### Manage Zones
130+
131+ ``` python
132+ # List all active zones
133+ zones = client.list_zones()
134+ print (f " Found { len (zones)} zones " )
135+ ```
142136
143137## API Reference
144138
145139### bdclient Class
146140
147- #### Constructor
148-
149141``` python
150142bdclient(
151143 api_token: str = None ,
152144 auto_create_zones: bool = True ,
153145 web_unlocker_zone: str = None ,
154- browser_zone: str = None
155146)
156147```
157148
158- #### Methods
159-
160- ** scrape(url, zone=None, format="json", method="GET", country="us", data_format="markdown", async_request=False, max_workers=None, timeout=None)**
161-
162- Scrape websites using Bright Data Web Unlocker API.
149+ ### Key Methods
163150
151+ #### scrape(...)
152+ Scrapes a single URL or list of URLs using the Web Unlocker.
153+ ``` python
164154- `url` : Single URL string or list of URLs
165155- `zone` : Zone identifier (auto- configured if None )
166156- `format ` : " json" or " raw"
@@ -170,31 +160,32 @@ Scrape websites using Bright Data Web Unlocker API.
170160- `async_request` : Enable async processing
171161- `max_workers` : Max parallel workers (default: 10 )
172162- `timeout` : Request timeout in seconds (default: 30 )
163+ ```
173164
174- ** search(query, search_engine="google", zone=None, format="json", method="GET", country="us", data_format="markdown", async_request=False, max_workers=None, timeout=None)**
175-
176- Search using Bright Data SERP API.
177-
165+ #### search(...)
166+ Searches using the SERP API. Accepts the same arguments as scrape(), plus:
167+ ``` python
178168- `query` : Search query string or list of queries
179169- `search_engine` : " google" , " bing" , or " yandex"
180170- Other parameters same as scrape()
171+ ```
181172
182- ** download_content(content, filename=None, format="json") **
173+ #### download_content(...)
183174
184175Save content to local file.
185-
176+ ``` python
186177- `content` : Content to save
187178- `filename` : Output filename (auto- generated if None )
188179- `format ` : File format (" json" , " csv" , " txt" , etc.)
180+ ```
189181
190- ** list_zones()**
182+ #### list_zones()
191183
192184List all active zones in your Bright Data account.
193185
194186## Error Handling
195187
196- The SDK includes comprehensive error handling:
197-
188+ The SDK includes built-in input validation and retry logic:
198189``` python
199190try :
200191 result = client.scrape(" https://example.com" )
@@ -214,33 +205,24 @@ except Exception as e:
214205
215206## Configuration Constants
216207
217- The SDK uses the following default values (configurable):
218-
219- - ` DEFAULT_MAX_WORKERS ` : 10 parallel workers
220- - ` DEFAULT_TIMEOUT ` : 30 seconds request timeout
221- - ` CONNECTION_POOL_SIZE ` : 20 HTTP connections
222- - ` MAX_RETRIES ` : 3 retry attempts
223- - ` RETRY_BACKOFF_FACTOR ` : 1.5x exponential backoff
208+ | Constant | Default | Description |
209+ | ---------------------- | ------- | ------------------------------- |
210+ | ` DEFAULT_MAX_WORKERS ` | ` 10 ` | Max parallel tasks |
211+ | ` DEFAULT_TIMEOUT ` | ` 30 ` | Request timeout (in seconds) |
212+ | ` CONNECTION_POOL_SIZE ` | ` 20 ` | Max concurrent HTTP connections |
213+ | ` MAX_RETRIES ` | ` 3 ` | Retry attempts on failure |
214+ | ` RETRY_BACKOFF_FACTOR ` | ` 1.5 ` | Exponential backoff multiplier |
224215
225216## Getting Your API Token
226217
227- 1 . Sign up at [ brightdata.com] ( https://brightdata.com/ )
228- 2 . Navigate to your dashboard
229- 3 . Create or access your API credentials
230- 4 . Copy your API token
231-
232- ## Requirements
233-
234- - Python 3.7+
235- - ` requests ` library
236- - ` python-dotenv ` (optional, for .env file support)
218+ 1 . Sign up at [ brightdata.com] ( https://brightdata.com/ ) , and navigate to your dashboard
219+ 2 . Create or access your API credentials
220+ 3 . Copy your API token and paste it in your .env or code file
237221
238222## License
239223
240224This project is licensed under the MIT License.
241225
242226## Support
243227
244- For issues related to the Bright Data service, contact [ Bright Data support] ( https://brightdata.com/support ) .
245-
246- For SDK-related issues, please open an issue in this repository.
228+ For any issues, contact [ Bright Data support] ( https://brightdata.com/contact ) , or open an issue in this repository.
0 commit comments