Skip to content

Commit

Permalink
google full image resolution try
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoongi Kim committed Dec 6, 2018
1 parent 02b46a9 commit ec5c10c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions collect_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,50 @@ def naver(self, keyword):
self.browser.close()

return links

def google_full(self, keyword):
self.browser.get("https://www.google.com/search?q={}&source=lnms&tbm=isch".format(keyword))

time.sleep(2)

first_photo_grid_boxes = self.browser.find_element(By.XPATH, '//img[@class="rg_ic rg_i"]')
print(first_photo_grid_boxes.get_attribute('id'))

first_photo_grid_boxes.click()

time.sleep(1)

container = self.browser.find_element(By.XPATH, '//div[@class="irc_land irc_bg"]')
print(container.get_attribute('id'))

img = container.find_element_by_id("irc-mi")
print(img.get_attribute('src'))

next_button = container.find_element(By.XPATH, '//div[@class="WPyac" and @id="irc-rac"]')
print(next_button.get_attribute('id'))
next_button.click()

input()

# print('Scraping links')
#
# links = []
#
# for box in photo_grid_boxes:
# imgs = box.find_elements(By.TAG_NAME, 'img')
#
# for img in imgs:
# src = img.get_attribute("src")
# if src[0] != 'd':
# links.append(src)
#
# print('Collect links done. Site: {}, Keyword: {}, Total: {}'.format('google', keyword, len(links)))
self.browser.close()

return links


if __name__ == '__main__':
collect = CollectLinks()
links = collect.google_full('python')
print(links)

0 comments on commit ec5c10c

Please sign in to comment.