Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. from splinter import Browser
  2.  
  3. url = "http://demos.ziftsolutions.com/sample/InnovativeTechnology/?a=qlik&wid=ff808181569b6fc10156a08e41a334b7&zPage=resources-d1ef094d"
  4.  
  5. browser = Browser('chrome')
  6. browser.visit(url)
  7.  
  8. g_links_found = browser.find_link_by_partial_href('?zPage=')
  9. wp_links_found = browser.find_link_by_partial_text('White Paper: ')
  10.  
  11. for link in wp_links_found:
  12. if link.target == "_blank":
  13. if link not in g_links_found:
  14. title = link.text[13:]
  15. try:
  16. link.click()
  17. if browser.is_text_present(title):
  18. docstatus = link.text + " is linking to the correct document."
  19. else:
  20. docstatus = link.text + " is not linking to the correct document."
  21. print docstatus
  22. except:
  23. print "Oops, I failed with " + link.text
  24. if link in g_links_found:
  25. docstatus = link.text + " is gated."
  26. print docstatus
  27. if link.target != "_blank":
  28. if link not in g_links_found:
  29. title = link.text[13:]
  30. try:
  31. link.click()
  32. if browser.is_text_present(title):
  33. docstatus = link.text + " is linking to the correct document."
  34. else:
  35. docstatus = link.text + " is not linking to the correct document."
  36. print docstatus
  37. except:
  38. print "Oops, I failed with " + link.text
  39. browser.back()
  40. if link in g_links_found:
  41. docstatus = link.text + " is gated."
  42. print docstatus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement