Created
October 27, 2016 19:36
-
-
Save nbari/8eeb79facc8b1a39a03a0ece4e5f0b8f to your computer and use it in GitHub Desktop.
web scraper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
driver = webdriver.Chrome() | |
driver.get("https://search.cro.ie/company/CompanySearch.aspx") | |
inputElement = driver.find_element_by_id("ctl00_ContentPlaceHolder1_textCompanyName") | |
inputElement.send_keys("limo") | |
inputElement.send_keys(Keys.ENTER) | |
links = driver.find_elements_by_xpath("//*[@id='ctl00_ContentPlaceHolder1_GridView1']/tbody/tr/td/a") | |
data = {} | |
for i in xrange(0, len(links)): | |
links = driver.find_elements_by_xpath("//*[@id='ctl00_ContentPlaceHolder1_GridView1']/tbody/tr/td/a") | |
idx_name = links[i].text | |
links[i].click() | |
div = driver.find_element_by_id("companyDetails") | |
data[idx_name] = div.text | |
driver.execute_script("window.history.go(-1)") | |
for key, value in sorted(data.iteritems()): | |
print "-" * 64 | |
print "%s\n%s" % (key, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment