ranjithkumar10

Browser automation

Dec 21st, 2016
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub PhantomTest()
  2. Dim driver As New WebDriver
  3. Dim posts As Object, post As Object
  4. Dim i As Long
  5. Set driver = New WebDriver
  6. driver.Start "Phantomjs", "http://www.yellowpages.com/"
  7. driver.get "/search?search_terms=Coffee+Shops&geo_location_terms=Los+Angeles%2C+CA"
  8. driver.Wait 2000
  9. Set posts = driver.FindElementsByClass("info")
  10. i = 2
  11. Worksheets("Sheet2").Select
  12. For Each post In posts
  13. Cells(i, 1).Value = post.FindElementByClass("business-name").Text
  14. Cells(i, 2).Value = post.FindElementByClass("adr").Text
  15. Cells(i, 3).Value = post.FindElementByClass("phones").Text
  16. i = i + 1
  17. Next post
  18. End Sub
  19. 'credits - https://codingislove.com
RAW Paste Data