You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -83,11 +83,11 @@ Modern async-first Python SDK for [Bright Data](https://brightdata.com) APIs wit
83
83
84
84
Perfect for data scientists! Interactive tutorials with examples:
85
85
86
-
1.**[01_quickstart.ipynb](notebooks/01_quickstart.ipynb)** - Get started in 5 minutes [](https://colab.research.google.com/github/brightdata/sdk-python/blob/master/notebooks/01_quickstart.ipynb)
87
-
2.**[02_pandas_integration.ipynb](notebooks/02_pandas_integration.ipynb)** - Work with DataFrames [](https://colab.research.google.com/github/brightdata/sdk-python/blob/master/notebooks/02_pandas_integration.ipynb)
88
-
3.**[03_amazon_scraping.ipynb](notebooks/03_amazon_scraping.ipynb)** - Amazon deep dive [](https://colab.research.google.com/github/brightdata/sdk-python/blob/master/notebooks/03_amazon_scraping.ipynb)
89
-
4.**[04_linkedin_jobs.ipynb](notebooks/04_linkedin_jobs.ipynb)** - Job market analysis [](https://colab.research.google.com/github/brightdata/sdk-python/blob/master/notebooks/04_linkedin_jobs.ipynb)
90
-
5.**[05_batch_processing.ipynb](notebooks/05_batch_processing.ipynb)** - Scale to 1000s of URLs [](https://colab.research.google.com/github/brightdata/sdk-python/blob/master/notebooks/05_batch_processing.ipynb)
86
+
1.**[01_quickstart.ipynb](notebooks/01_quickstart.ipynb)** - Get started in 5 minutes [](https://colab.research.google.com/github/brightdata/sdk-python/blob/main/notebooks/01_quickstart.ipynb)
87
+
2.**[02_pandas_integration.ipynb](notebooks/02_pandas_integration.ipynb)** - Work with DataFrames [](https://colab.research.google.com/github/brightdata/sdk-python/blob/main/notebooks/02_pandas_integration.ipynb)
88
+
3.**[03_amazon_scraping.ipynb](notebooks/03_amazon_scraping.ipynb)** - Amazon deep dive [](https://colab.research.google.com/github/brightdata/sdk-python/blob/main/notebooks/03_amazon_scraping.ipynb)
89
+
4.**[04_linkedin_jobs.ipynb](notebooks/04_linkedin_jobs.ipynb)** - Job market analysis [](https://colab.research.google.com/github/brightdata/sdk-python/blob/main/notebooks/04_linkedin_jobs.ipynb)
90
+
5.**[05_batch_processing.ipynb](notebooks/05_batch_processing.ipynb)** - Scale to 1000s of URLs [](https://colab.research.google.com/github/brightdata/sdk-python/blob/main/notebooks/05_batch_processing.ipynb)
91
91
92
92
---
93
93
@@ -149,9 +149,9 @@ client = BrightDataClient()
149
149
result = client.scrape.generic.url("https://example.com")
result = client.scrape.chatgpt.prompt(prompt="Explain Python", web_search=True)
1073
+
1074
+
# ASYNC - Batch prompts
1075
+
asyncdefask_chatgpt():
1076
+
asyncwith BrightDataClient() as client:
1077
+
result =await client.scrape.chatgpt.prompts_async(
1078
+
prompts=["What is Python?", "What is JavaScript?"],
1079
+
web_searches=[False, True]
1080
+
)
1081
+
return result
1082
+
1083
+
result = asyncio.run(ask_chatgpt())
1084
+
```
1085
+
1086
+
#### **Generic Web Scraping**
1087
+
1088
+
```python
1089
+
# SYNC - Single URL
1090
+
result = client.scrape.generic.url(url="https://example.com")
1091
+
1092
+
# ASYNC - Concurrent scraping
1093
+
asyncdefscrape_multiple():
1094
+
asyncwith BrightDataClient() as client:
1095
+
results =await client.scrape.generic.url_async([
1096
+
"https://example1.com",
1097
+
"https://example2.com",
1098
+
"https://example3.com"
1099
+
])
1100
+
return results
1101
+
1102
+
results = asyncio.run(scrape_multiple())
1103
+
```
1104
+
1105
+
---
1106
+
1107
+
### **When to Use Sync vs Async**
1108
+
1109
+
**Use Sync When:**
1110
+
- ✅ Simple scripts or notebooks
1111
+
- ✅ Single operations at a time
1112
+
- ✅ Learning or prototyping
1113
+
- ✅ Sequential workflows
1114
+
1115
+
**Use Async When:**
1116
+
- ✅ Scraping multiple URLs concurrently
1117
+
- ✅ Combining multiple API calls
1118
+
- ✅ Production applications
1119
+
- ✅ Performance-critical operations
1120
+
950
1121
**Note:** Sync wrappers (e.g., `profiles()`) internally use `asyncio.run()` and cannot be called from within an existing async context. Use `*_async` methods when you're already in an async function.
0 commit comments