Try95th

examplesOf__linkToSoup_selenium.py

Nov 13th, 2022 (edited)
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. from linkToSoup_selenium import * ## download or paste from https://pastebin.com/kEC9gPC8 ##
  2.  
  3. #### for an API with blocker [cloudflare in this case] ####
  4. soup = linkToSoup_selenium('https://api-mainnet.magiceden.io/launchpads/planetarians') 
  5. if soup is not None: print(json.loads(soup.text)['_id'])    
  6.     ## prints '6242a300ba826f001186ff68' ##
  7. ###########################################################
  8.  
  9. ####### for a site that loads data with javascript ####### 
  10. soup = linkToSoup_selenium(
  11.     l = 'https://www.cnbc.com/search/?query=green%20hydrogen'  
  12.   , ecx = '//span[@class="Card-title"]'
  13.   # , clickFirst = [] # nothing needs to be clicked to proceed 
  14. )  
  15. if soup is not None: for c in soup.select('span.Card-title'): print(c.text)
  16.     ## prints all the article headings ##  
  17. ###########################################################
  18.  
  19. #### for a site with 2 pop-up dialogs to be dealt with ####
  20. soup = linkToSoup_selenium(
  21.     l = 'http://www.finewineandgoodspirits.com'
  22.   # , ecx = [] # not necessary 
  23.   , clickFirst=[   
  24.       '//button[@id="ltkpopup-age-gate-yes"]',  ## confirm age 21+
  25.       '//div[@id="ltkpopup-close-button"]//a'   ## close popup asking for email
  26.     ]  
  27. )  
  28. if soup is not None: print(fSoup.select_one('.content_home .productContainer .productDiscHeader').text)
  29.     ## prints 'Jack Daniel's Gentleman Jack Double Mellowed Tennessee Whiskey 80 Proof' ##  
  30. ###########################################################
Advertisement
Add Comment
Please, Sign In to add comment