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
**Important:** When using `*_async` methods, always use the async context manager (`async with BrightDataClient() as client`). Sync wrappers (methods without `_async`) handle this automatically.
@@ -600,9 +605,9 @@ The SDK includes a powerful CLI tool:
600
605
# Help
601
606
brightdata --help
602
607
603
-
# Scrape Amazon product
608
+
# Scrape Amazon product (URL is positional argument)
604
609
brightdata scrape amazon products \
605
-
--url "https://amazon.com/dp/B0CRMZHDG8" \
610
+
"https://amazon.com/dp/B0CRMZHDG8" \
606
611
--output-format json
607
612
608
613
# Search LinkedIn jobs
@@ -612,14 +617,14 @@ brightdata search linkedin jobs \
612
617
--remote \
613
618
--output-file jobs.json
614
619
615
-
# Search Google
620
+
# Search Google (query is positional argument)
616
621
brightdata search google \
617
-
--query "python tutorial" \
622
+
"python tutorial" \
618
623
--location "United States"
619
624
620
-
# Generic web scraping
625
+
# Generic web scraping (URL is positional argument)
621
626
brightdata scrape generic \
622
-
--url "https://example.com" \
627
+
"https://example.com" \
623
628
--output-format pretty
624
629
```
625
630
@@ -799,8 +804,7 @@ result = client.scrape.amazon.reviews(
799
804
url="https://amazon.com/dp/B123",
800
805
pastDays=7, # Last 7 days only
801
806
keyWord="quality", # Filter by keyword
802
-
numOfReviews=50, # Limit to 50 reviews
803
-
sync=True
807
+
numOfReviews=50# Limit to 50 reviews
804
808
)
805
809
806
810
# LinkedIn jobs with extensive filters
@@ -816,24 +820,31 @@ result = client.search.linkedin.jobs(
816
820
)
817
821
```
818
822
819
-
### Sync vs Async Modes
823
+
### Sync vs Async Methods
820
824
821
825
```python
822
-
# Sync mode (default) - immediate response
826
+
# Sync wrapper - for simple scripts (blocks until complete)
823
827
result = client.scrape.linkedin.profiles(
824
828
url="https://linkedin.com/in/johndoe",
825
-
sync=True, # Immediate response (faster but limited timeout)
826
-
timeout=65# Max 65 seconds
829
+
timeout=300# Max wait time in seconds
827
830
)
828
831
829
-
# Async mode - polling for long operations
830
-
result = client.scrape.linkedin.profiles(
831
-
url="https://linkedin.com/in/johndoe",
832
-
sync=False, # Trigger + poll (can wait longer)
833
-
timeout=300# Max 5 minutes
834
-
)
832
+
# Async method - for concurrent operations (requires async context)
833
+
import asyncio
834
+
835
+
asyncdefscrape_profiles():
836
+
asyncwith BrightDataClient() as client:
837
+
result =await client.scrape.linkedin.profiles_async(
838
+
url="https://linkedin.com/in/johndoe",
839
+
timeout=300
840
+
)
841
+
return result
842
+
843
+
result = asyncio.run(scrape_profiles())
835
844
```
836
845
846
+
**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.
847
+
837
848
### SSL Certificate Error Handling
838
849
839
850
The SDK includes comprehensive SSL error handling with platform-specific guidance:
@@ -1100,11 +1111,10 @@ if client.test_connection_sync():
1100
1111
)
1101
1112
1102
1113
if product.success:
1103
-
print(f"Product: {product.data['title']}")
1104
-
print(f"Price: {product.data['price']}")
1105
-
print(f"Rating: {product.data['rating']}")
1114
+
print(f"Product: {product.data[0]['title']}")
1115
+
print(f"Price: {product.data[0]['final_price']}")
1116
+
print(f"Rating: {product.data[0]['rating']}")
1106
1117
print(f"Cost: ${product.cost:.4f}")
1107
-
print(f"Method: {product.method}") # "web_scraper", "web_unlocker", etc.
1108
1118
1109
1119
# Search LinkedIn jobs
1110
1120
jobs = client.search.linkedin.jobs(
@@ -1113,25 +1123,28 @@ if client.test_connection_sync():
0 commit comments