Instantly share code, notes, and snippets.

Embed
What would you like to do?
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2; .NET4.0E)")
service_args = [
'--ssl-protocol=tlsv1'
]
driver = webdriver.PhantomJS(desired_capabilities=dcap, service_args=service_args, executable_path="/Users/kzfm/.nvm/versions/node/v5.1.0/bin/phantomjs")
url = "https://www.release.tdnet.info/index.html"
driver.get(url)
driver.save
#iframe = driver.find_element_by_tag_name("iframe")
#driver.switch_to_frame(iframe)
#driver.find_element_by_name("q").send_keys("66160")
# driver.find_element_by_name("q").send_keys(Keys.RETURN)
# time.sleep(2)
# result_frame = self.driver.find_element_by_name("mainlist")
# self.driver.switch_to_frame(result_frame)
# main_table = self.driver.find_element_by_id("maintable")
# for tr in main_table.find_elements_by_tag_name("tr"):
# company_name = tr.find_element_by_class_name("companyname").text
# published_string = tr.find_element_by_class_name("time").text
# t = tr.find_element_by_class_name("title")
# title = t.find_element_by_tag_name("a").text
# url = t.find_element_by_tag_name("a").get_attribute("href")
# updated = datetime.strptime(published_string, "%Y/%m/%d %H:%M")
# published = datetime.strptime(published_string, "%Y/%m/%d %H:%M")
# print company_name, title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment