File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
src/brightdata/scrapers/amazon Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -129,13 +129,14 @@ async def products_async(
129129 payload = []
130130 for i in range (batch_size ):
131131 item = {}
132-
132+
133133 # If URL provided directly, use it
134134 if urls and i < len (urls ):
135135 item ["url" ] = urls [i ]
136136 # Extract keyword from URL if possible for the keyword field
137137 if "k=" in urls [i ]:
138138 import urllib .parse
139+
139140 parsed = urllib .parse .urlparse (urls [i ])
140141 params = urllib .parse .parse_qs (parsed .query )
141142 item ["keyword" ] = params .get ("k" , ["" ])[0 ]
@@ -144,7 +145,7 @@ async def products_async(
144145 else :
145146 # Send keyword directly (dataset expects this field)
146147 item ["keyword" ] = keywords [i ] if keywords and i < len (keywords ) else ""
147-
148+
148149 # Optionally build URL for additional context
149150 if item ["keyword" ]:
150151 search_url = self ._build_amazon_search_url (
@@ -157,7 +158,7 @@ async def products_async(
157158 country = countries [i ] if countries and i < len (countries ) else None ,
158159 )
159160 item ["url" ] = search_url
160-
161+
161162 payload .append (item )
162163
163164 return await self ._execute_search (
You can’t perform that action at this time.
0 commit comments