<jupyter_start><jupyter_text>Scraping!!! Yeah!<jupyter_code>from selenium import webdriver
url = 'http://corners.gmarket.co.kr/Bestsellers'
driver = webdriver.Chrome()
driver.get(url)
# .best-list 와 같이 .은 class
# #은 id
# 아무것도 없으면 그냥
# 여러개 찾을때는 find_elements_by
items = driver.find_elements_by_css_selector('.best-list > ul > li')
len(items)

#우리는 Best 200 product를 찾기 때문에 nth-child써야 됨
items = driver.find_elements_by_css_selector('.best-list:nth-child(3) > ul > li')
len(items)
dict_list = []

for item in items:
    dict_list.append({
        'title': item.find_element_by_css_selector('.itemname').text,
        'link': item.find_element_by_css_selector('.itemname').get_attribute('href'),
        'o-price': item.find_element_by_css_selector('.o-price').text.replace(',', '')[:-1],
        's-price': item.find_element_by_css_selector('.s-price').text.split(' ')[0].replace(',', '')[:-1]
    })
print(dict_list)
df = pd.DataFrame(dict_list)
df
df['o-price'][df['o-price'] == ''] 
df['s-price'][df['o-price'] == '']
df['o-price'][df['o-price'] == ''] = df['s-price'][df['o-price'] == '']
df
# 할인율 컬럼 추가
df['discount_rate'] = round((1 - df['s-price'].astype('int') / df['o-price'].astype('int')) * 100, 0)
df['discount_rate'] = df['discount_rate'].astype('int')
df['discount_rate'] = df['discount_rate'].astype('str')
df['discount_rate'] += '%'
df
driver.quit()<jupyter_output><empty_output><jupyter_text>Google Vision Crawling<jupyter_code>from selenium import webdriver
url = 'https://cloud.google.com/vision/'
driver = webdriver.Chrome()
driver.get(url)
iframe = driver.find_element_by_css_selector('#vision_demo_section > iframe')
driver.switch_to_frame(iframe)
file_path = 'C:\\Users\\JongJae\\Downloads\\dog.png'
driver.find_element_by_css_selector('#input').send_keys(file_path)
driver.find_element_by_css_selector('#webDetection').click()<jupyter_output><empty_output><jupyter_text>Naver Crawling<jupyter_code>from selenium import webdriver
main_url = 'http://naver.com'
mail_url = 'https://mail.naver.com'
driver = webdriver.Chrome()
driver.get(main_url)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1928400954653938, 'fraction_numerical': 0.005727923627684964, 'mean_word_length': 6.277777777777778, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '236616', 'license': 'MIT', 'n_tokens_mistral': 844, 'n_tokens_neox': 849, 'n_words': 112, 'path': '2018_06_21_Review_Funny_Crawling.ipynb', 'repo_name': 'jaykim-asset/datascience_review', 'size': '2095'}