In [3]:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from BeautifulSoup import BeautifulSoup
import MySQLdb as mdb
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
import sys


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-aed57d79a58f> in <module>()
      3 from selenium.webdriver.support.ui import WebDriverWait
      4 from BeautifulSoup import BeautifulSoup
----> 5 import MySQLdb as mdb
      6 from selenium.webdriver.support import expected_conditions as EC
      7 from selenium.webdriver.common.by import By

ImportError: No module named MySQLdb

In [2]:
driver = webdriver.Chrome('/Users/David/python_lib/chromedriver')  # Optional argument, if not specified will search path.
# driver.get('http://www.google.com/xhtml');
driver.get('https://cgmix.uscg.mil/PSIX/PSIXSearch.aspx')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-e205aa9b97fe> in <module>()
----> 1 driver = webdriver.Chrome('/Users/David/python_lib/chromedriver')  # Optional argument, if not specified will search path.
      2 driver.get('https://sd.ic.gc.ca/pls/engdoc_anon/mmsi_search.ship')

NameError: name 'webdriver' is not defined

In [35]:
elem = driver.find_element_by_id('TextBoxVesselYear')  # Find the search box
elem.send_keys('1990')

elem = driver.find_element_by_id('TextBoxVesselName')  # Find the search box
elem.send_keys('b')

In [36]:
el = driver.find_element_by_name('DropDownListService')
for option in el.find_elements_by_tag_name('option'):
    #print option.text
    if "Commercial Fishing" in option.text:
        option.click()

In [37]:
driver.find_element_by_name("ButtonSearch").click()

html = driver.page_source

In [42]:


In [55]:
elem = driver.find_element_by_id('GridViewPSIX')  # find the table

for row in elem.find_elements_by_tag_name("tr"):
    cell = row.find_elements_by_tag_name("td")
    if len(cell) == 8:
        links =  cell[0].find_elements_by_tag_name('a')
        print cell[2].text, len(cell)
        links[0].click()
        break
    
#         print cell[0].text
#     break


PR1944BB 8

In [53]:
driver.back()

In [ ]: