Advertisement
gasaichan

a

Jun 28th, 2021
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. from time import time
  2. from selenium.webdriver.chrome.options import Options
  3. from seleniumwire import webdriver
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.support.ui import WebDriverWait
  6. from selenium.webdriver.support import expected_conditions as EC
  7. from seleniumwire.request import Request, Response
  8.  
  9.  
  10. def main():
  11. chrome_options = Options()
  12. chrome_options.headless = True
  13.  
  14. driver = webdriver.Chrome(
  15. options=chrome_options,
  16. seleniumwire_options={
  17. 'disable_encoding': True
  18. })
  19.  
  20. driver.response_interceptor = response_interceptor
  21.  
  22. driver.get('https://telemetr.me/channels/cat/%D0%91%D0%B8%D0%B7%D0%BD%D0%B5%D1%81%20%D0%B8%20%D1%84%D0%B8%D0%BD%D0%B0%D0%BD%D1%81%D1%8B/?page=1')
  23. elem = driver.find_element_by_css_selector(
  24. '[data-do="show_dynamic_participants"]')
  25. elem.click()
  26.  
  27. # request = driver.wait_for_request('/index.php')
  28. input()
  29. # print(driver.last_request.body.decode('utf-8'))
  30.  
  31.  
  32. def response_interceptor(request: Request, response: Response):
  33. if ('index.php' in request.url):
  34. print(response.body)
  35.  
  36.  
  37. if __name__ == '__main__':
  38. main()
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement