@@ -312,6 +312,33 @@ def test_google_search():
312312 raise
313313
314314
315+ # ============================================
316+ # Fast Search API
317+ # ============================================
318+
319+ def test_fast_search ():
320+ print ("=== Testing Fast Search API ===" )
321+ try :
322+ response = client .fast_search (
323+ search = "scrapingbee" ,
324+ params = {"country_code" : "us" , "language" : "en" }
325+ )
326+
327+ assert_test (response .status_code == 200 , f"Expected status 200, got { response .status_code } " )
328+
329+ data = response .json ()
330+ assert_test (data .get ("organic" ), "Missing organic in response" )
331+ assert_test (isinstance (data .get ("organic" ), list ), "organic is not a list" )
332+ assert_test (len (data .get ("organic" , [])) > 0 , "No organic results found" )
333+
334+ print (f"Status: { response .status_code } " )
335+ print (f"Results found: { len (data .get ('organic' , []))} " )
336+ print ("✅ Fast Search test passed!\n " )
337+ except Exception as e :
338+ print (f"❌ Fast Search test failed: { e } \n " )
339+ raise
340+
341+
315342# ============================================
316343# Amazon API
317344# ============================================
@@ -360,6 +387,28 @@ def test_amazon_product():
360387 raise
361388
362389
390+ def test_amazon_pricing ():
391+ print ("=== Testing Amazon Pricing API ===" )
392+ try :
393+ response = client .amazon_pricing (
394+ asin = "B0DPDRNSXV" ,
395+ params = {"domain" : "com" }
396+ )
397+
398+ assert_test (response .status_code == 200 , f"Expected status 200, got { response .status_code } " )
399+
400+ data = response .json ()
401+ assert_test (data .get ("pricing" ) is not None or data .get ("asin" ), "Missing pricing data in response" )
402+
403+ print (f"Status: { response .status_code } " )
404+ print (f"ASIN: { data .get ('asin' )} " )
405+ print (f"Offers: { len (data .get ('pricing' , []))} " )
406+ print ("✅ Amazon Pricing test passed!\n " )
407+ except Exception as e :
408+ print (f"❌ Amazon Pricing test failed: { e } \n " )
409+ raise
410+
411+
363412# ============================================
364413# Walmart API
365414# ============================================
@@ -453,56 +502,63 @@ def test_youtube_metadata():
453502 raise
454503
455504
456- def test_youtube_transcript ():
457- print ("=== Testing YouTube Transcript API ===" )
505+ def test_youtube_subtitles ():
506+ print ("=== Testing YouTube Subtitles API ===" )
458507 try :
459- response = client .youtube_transcript (
460- video_id = "sfyL4BswUeE " ,
508+ response = client .youtube_subtitles (
509+ video_id = "dQw4w9WgXcQ " ,
461510 params = {"language" : "en" }
462511 )
463512
464513 assert_test (response .status_code == 200 , f"Expected status 200, got { response .status_code } " )
465514
466515 data = response .json ()
467- assert_test (data .get ("text" ) or data . get ( "transcript" ) , "Missing transcript in response" )
516+ assert_test (data .get ("subtitles" ) , "Missing subtitles in response" )
468517
469- transcript_preview = (data .get ("text" ) or str (data .get ("transcript" , "" )))[:100 ]
470518 print (f"Status: { response .status_code } " )
471- print (f"Transcript preview : { transcript_preview } " )
472- print ("✅ YouTube Transcript test passed!\n " )
519+ print (f"Subtitle origins : { list ( data . get ( 'subtitles' , {}). keys ()) } " )
520+ print ("✅ YouTube Subtitles test passed!\n " )
473521 except Exception as e :
474- print (f"❌ YouTube Transcript test failed: { e } \n " )
522+ print (f"❌ YouTube Subtitles test failed: { e } \n " )
475523 raise
476524
477525
478- def test_youtube_trainability ():
479- print ("=== Testing YouTube Trainability API ===" )
526+ # ============================================
527+ # ChatGPT API
528+ # ============================================
529+
530+ def test_chatgpt ():
531+ print ("=== Testing ChatGPT API ===" )
480532 try :
481- response = client .youtube_trainability (video_id = "dQw4w9WgXcQ" )
533+ response = client .chatgpt (
534+ prompt = "What is web scraping? Answer in one sentence." ,
535+ params = {"search" : True }
536+ )
482537
483538 assert_test (response .status_code == 200 , f"Expected status 200, got { response .status_code } " )
484539
485540 data = response .json ()
486- assert_test (data .get ("permitted " ) is not None , "Missing permitted field in response" )
541+ assert_test (data .get ("results_text " ) or data . get ( "results_markdown" ) , "Missing response text " )
487542
543+ response_text = (data .get ("results_text" ) or data .get ("results_markdown" , "" ))[:100 ]
488544 print (f"Status: { response .status_code } " )
489- print (f"Permitted : { data . get ( 'permitted' ) } " )
490- print ("✅ YouTube Trainability test passed!\n " )
545+ print (f"Response : { response_text } " )
546+ print ("✅ ChatGPT test passed!\n " )
491547 except Exception as e :
492- print (f"❌ YouTube Trainability test failed: { e } \n " )
548+ print (f"❌ ChatGPT test failed: { e } \n " )
493549 raise
494550
495551
496552# ============================================
497- # ChatGPT API
553+ # Gemini API
498554# ============================================
499555
500- def test_chatgpt ():
501- print ("=== Testing ChatGPT API ===" )
556+ def test_gemini ():
557+ print ("=== Testing Gemini API ===" )
502558 try :
503- response = client .chatgpt (
559+ response = client .gemini (
504560 prompt = "What is web scraping? Answer in one sentence." ,
505- params = {"search " : True }
561+ params = {"country_code " : "us" }
506562 )
507563
508564 assert_test (response .status_code == 200 , f"Expected status 200, got { response .status_code } " )
@@ -513,9 +569,9 @@ def test_chatgpt():
513569 response_text = (data .get ("results_text" ) or data .get ("results_markdown" , "" ))[:100 ]
514570 print (f"Status: { response .status_code } " )
515571 print (f"Response: { response_text } " )
516- print ("✅ ChatGPT test passed!\n " )
572+ print ("✅ Gemini test passed!\n " )
517573 except Exception as e :
518- print (f"❌ ChatGPT test failed: { e } \n " )
574+ print (f"❌ Gemini test failed: { e } \n " )
519575 raise
520576
521577
@@ -570,15 +626,17 @@ def run_tests():
570626
571627 # Other APIs
572628 test_google_search ,
629+ test_fast_search ,
573630 test_amazon_search ,
574631 test_amazon_product ,
632+ test_amazon_pricing ,
575633 test_walmart_search ,
576634 test_walmart_product ,
577635 test_youtube_search ,
578636 test_youtube_metadata ,
579- test_youtube_transcript ,
580- test_youtube_trainability ,
637+ test_youtube_subtitles ,
581638 test_chatgpt ,
639+ test_gemini ,
582640 test_usage ,
583641 ]
584642
0 commit comments