Created
August 21, 2016 20:21
-
-
Save linlincheng/bdea2097d354a1aa56f135e96a732238 to your computer and use it in GitHub Desktop.
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
#Step 3. | |
##Retrieving urls for each of the events to be looped through | |
sub_url_list=[] | |
for eve in tmp_list: | |
try: | |
sub_url = eve['url'] | |
sub_url_list.append(sub_url) | |
except: | |
print "error"+str(IOError) | |
pass | |
print '.' | |
##find the specific url for each item and store them in item_url_list: | |
import time | |
from selenium.webdriver.common.action_chains import ActionChains | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
item_url_list = [] | |
driver = webdriver.Chrome() | |
for sub_url in sub_url_list[0:1001]: | |
try: | |
driver.get(sub_url) | |
try: | |
driver.find_element_by_class('christies-icon_close closeiframe').click() | |
except: | |
pass | |
try: | |
element = driver.find_element_by_id("loadAllUpcomingPast") | |
hov = ActionChains(driver).move_to_element(element) | |
hov.perform() | |
element.click() | |
print 'loaded all' | |
except: | |
pass | |
time.sleep(5) | |
a_list1 = driver.find_elements_by_class_name("cta-image") | |
print len(a_list1) | |
item_url_sub = map(lambda x: x.get_attribute('href').\ | |
encode('ascii', 'ignore').strip(), a_list1) | |
item_url_list1.append(item_url_sub) | |
except: | |
print driver.current_url | |
pass | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment