def exploiteLegumes(): browser = webdriver.Chrome( executable_path= r"C:\\Users\\frup68962\\Downloads\\chromedriver_win32\\chromedriver.exe" ) file = codecs.open('D:\\pmu\\Package\\data\\source.html', 'r', 'utf-8') for line in file: if re.search( r'.*?((<a href=")(.*?)(onmouseout="document.getElementById))', line): listFruit = line.split('"')[1] browser.get("https://www.fruits-legumes.org/" + listFruit) time.sleep(5) soup = BeautifulSoup(browser.page_source, 'lxml') writeFile(soup.prettify(), 'D:\\pmu\\Package\\data\\legumes.html') fileLegumes = codecs.open('D:\\pmu\\Package\\data\\legumes.html', 'r', 'utf-8') for linelegumes in fileLegumes: if re.search(r'.*?((<img alt=")(.*?)(.jpg"/>))', linelegumes): nom = linelegumes.split('"')[1] adres = linelegumes.split('"')[3] print('{} - {}'.format(nom, adres)) resource = urllib.request.urlretrieve( "https://www.fruits-legumes.org/" + adres, "C:\\Images\\" + nom + ".jpg") dload.save("https://www.fruits-legumes.org/" + adres) print("https://www.fruits-legumes.org/" + adres)
def downloadImages(html): for x in re.finditer(r'https?:\/\/[^ ]*\/(.*?)\.(png|jpe?g|gif)', html, flags=re.IGNORECASE): url = x.group() filename = os.path.basename(url) print('Downloading {}...'.format(url)) dload.save(url, 'build/img/' + filename) html = html.replace(url, 'img/' + filename) return html
def crawl(): _current_dir = os.path.dirname(os.path.abspath(__file__)) _path = Path(_current_dir) BASE_DIR = _path.parent.absolute() IMG_DIR = f'{BASE_DIR}/img/netflix' DATE_FORMAT = '%Y%m%d' today = datetime.datetime.now() fToday = today.strftime(DATE_FORMAT) TARGET_DIR = f'{IMG_DIR}/{fToday}' # generate folder isGenerated = create_folder(TARGET_DIR) if isGenerated is False: pass else: TARGET_URL = 'https://movie.daum.net/premovie/netflix?flag=Y' TARGET_SELECTOR = '.item_poster' _req = requests.get(TARGET_URL) _req.encoding = None html = _req.content _soup = BeautifulSoup(html, 'html.parser') # 정보 크롤링 infos = _soup.select(TARGET_SELECTOR) container = {} for info in infos: title = info.select_one('.thumb_cont > .tit_item > a').text date = info.select_one('.thumb_cont > .txt_info > .txt_num').text container[title] = date _check_img = info.select_one('.thumb_item > .poster_movie > img') if _check_img is None: del container[title] continue title_remove_white = regex.change_whitespace(title) title_remove_spical = regex.change_file_disable(title_remove_white) img = info.select_one('.thumb_item > .poster_movie > img')['src'] dload.save(img, f'{TARGET_DIR}/{title_remove_spical}.png') # post tweet try: imageTweetTest.post_tweet(container, fToday) except Exception as e: print(e)
def download_image(attribute): if thumbnail[attribute].split(':')[0] == 'data': # with open(f'./1st_homework_img/nier_official_{index}.jpg', 'wb') as img_file: # img_file.write(base64.b64decode(str(thumbnail[attribute]))) mime_type = thumbnail[attribute] data = mime_type[mime_type.find('/9'):] Image.open(io.BytesIO(base64.b64decode(data))).save( f'./1st_homework_img/nier_official_{index}.jpg') else: dload.save(thumbnail[attribute], f'./1st_homework_img/nier_official_{index}.jpg')
def crawl(): today = util._get_date(datetime.datetime.now()) IMG_DIR = util._get_img_dir(__file__, DIR_NAME) TARGET_DIR = f'{IMG_DIR}/{today}' isGenerate = util._create_folder(TARGET_DIR) if isGenerate is False: return target_url = [TARGET_URL_MUSICAL] selector = '.rankBody' container = [] img_counter = 0 for t_url in target_url: # crawl from web _req = requests.get(t_url) _req.encoding = None html = _req.content _soup = BeautifulSoup(html, 'html.parser') infos = _soup.select(selector) for info in infos: # parsing title = info.select_one('.prdInfo')['title'] _place = info.select_one('.prdInfo > a').contents[2] _place2 = _place.replace('\r\n\t', '') place = _place2.strip() _date = info.select_one('.prdDuration').text date = _date.strip() container.append(f'TITLE: {title}\n\n공연장: {place}\n기간: {date}') img = info.select_one('.prds > a > img')['src'] dload.save(img, f'{TARGET_DIR}/{img_counter}.png') img_counter = img_counter + 1 imageTweetTest.post_tweet_list(container, TARGET_DIR, keys)
def download_cve_json(date): """ download cve json file :return: """ count = 0 for name in name_list: file = 'file_use/{}.txt'.format(date) if not os.path.exists(file): os.mknod(file) with open(file, 'a') as fa: fa.write(name+'\n') # 重组url s_name = name.split('-') year = s_name[0] number = s_name[1] s_number = number[:-3] # 分割数字,重组所需的数据 t_number = s_number + 'xxx' # print(t_number) url1 = 'https://raw.githubusercontent.com/CVEProject/cvelist/master/' t_url = url1 + year + '/' + t_number + '/CVE-' + name + '.json' # print(t_url) # list_href.append(t_url) # 创建文件夹并下载到文件夹 file1 = '/home/shijiuyi/Desktop/other_crawl/crawl_cve/cve-json/{}'.format(date) # print(file) if not os.path.exists(file1): os.mkdir(file1) j_file = file1 + '/{}.json'.format(name) try: dload.save(t_url, j_file) except: try: dload.save(t_url, j_file) except: with open('file_use/{}-name.txt', 'a') as f: f.write(name+'\n') count += 1 print('download json success: {} {}'.format(name, count)) time.sleep(1)
import dload from bs4 import BeautifulSoup from selenium import webdriver import time driver = webdriver.Chrome('chromedriver') # 웹드라이버 파일의 경로 driver.get("https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%EC%95%84%EC%9D%B4%EC%9C%A0") time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source # HTML을 BeautifulSoup이라는 라이브러리를 활용해 검색하기 용이한 상태로 만듦 # soup이라는 변수에 "파싱 용이해진 html"이 담긴 상태가 됨 # 이제 코딩을 통해 필요한 부분을 추출하면 된다. soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select('#imgList > div > a > img') i=1 for thumbnail in thumbnails: img = thumbnail['src'] dload.save(img, f'img/{i}.jpg') # f 를 써주고, {i} 를 입력하면, i 에 숫자가 반복문을 돌면서 들어감 1.jpg , 2.jpg 등등 i+=1
browser.find_element_by_css_selector( '#tsf > div:nth-child(2) > div.A8SBwf > div.FPdoLc.tfB0Bf > center > input.gNO89b' ).click() # 스타벅스 상품페이지 browser.find_element_by_css_selector( '#rso > div:nth-child(1) > div > table > tbody > tr.mslg.c9EJob > td:nth-child(1) > div > span > h3 > a' ).click() # productHtml productHtml = browser.page_source soup = bs(productHtml, 'html.parser') # 타이틀 크롤링 titles = soup.select('#product_view_tab01 > div.product_list > dl > dt > a') for idx, title in enumerate(titles): # 폴더생성 createDirectory(f'imgs/{title.text}') # 이미지 크롤링 getImgs(idx) imgs = soup.select( f'#product_view_tab01 > div.product_list > dl > dd:nth-child({(idx + 1) * 2}) > ul > li > dl > dt > a > img' ) # 이미지 저장 for i, img in enumerate(imgs): dload.save(img['src'], f'imgs/{title.text}/{title.text}{1 + i}.jpg') print(f'<<< {title.text} 완료 >>>') browser.quit()
import dload dload.save("https://spartacodingclub.kr/static/css/images/ogimage.png", 'sparta.png') dload.save( "테스트용나이ㅜ림ㄴ2F23%2F0002917427_001_20180523181610317.jpg&type=sc960_832", 'dog.png') #load.save
from bs4 import BeautifulSoup from selenium import webdriver import time import dload driver = webdriver.Chrome('chromedriver') driver.get("https://search.daum.net/search?nil_suggest=btn&w=img&DA=SBC&q=%EB%B0%95%EB%B3%B4%EC%98%81") time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') i = 1 thumbnails = soup.select('#imgList > div > a > img') for thumbnail in thumbnails: img = thumbnail['src'] dload.save(img, f'1일차/img/{i}.png') i += 1 driver.quit()
from datetime import datetime import dload import matplotlib.pyplot as plt import numpy as np # Default Output format def log(text): line = '---->' print(line, text) # load data from repo try: log('getting data') dload.save('https://covid.ourworldindata.org/data/owid-covid-data.csv', 'COVID-19.csv') except: log('data exists already') # pass arguments args = sys.argv # gives value of Country namme def getCountrydata(countryname): with open('./COVID-19.csv') as csvfile: readcsv = csv.reader(csvfile, delimiter=',') data = [] for row in readcsv: if countryname in row[2]: if len(countryname) == len(row[2]):
# # 가상환경이란! # 집에서는 패키지를 b,c,d,e를 쓰고 # 회사에서는 a b c를 써 # 그래서 b를 이전버전 b'를 써! # # 나는 회사랑 집이랑 b, b'를 써야 되니까.. 귀찮아서 # 그래서 이 라이브러리를 프로젝트 별로 관리할 수 있게 폴더별로 만들어서 관리한다 # 이걸 가상환경이라는 개념으로 부른다 # v-env!! 가상환경 라이브러리를 담는 곳 # web-scraping이라는 프로젝트를 실행시킬때는 # 여기 v-env에서 라이브러리 갖다쓰고, 여기에다가 깔아서 써 # 그래야 충돌이 안나! -> 가상환경의 개념! # 이런건 사실 근데 파이참이 다 알아서 잡아줘... # dload는 url을 넣으면 이미지를 다운받게 해주는 패키지!! import dload dload.save("https://spartacodingclub.kr/static/css/images/ogimage.png")
import dload from bs4 import BeautifulSoup from selenium import webdriver import time driver = webdriver.Chrome('./chromedriver') # 웹드라이버 파일의 경로 driver.get("https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%EC%95%84%EC%9D%B4%EC%9C%A0") time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source # HTML을 BeautifulSoup이라는 라이브러리를 활용해 검색하기 용이한 상태로 만듦 # soup이라는 변수에 "파싱 용이해진 html"이 담긴 상태가 됨 # 이제 코딩을 통해 필요한 부분을 추출하면 된다. soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select('#imgList > div > a > img') i = 1 for thumbnail in thumbnails: src = thumbnail["src"] dload.save(src, f'images/{i}.jpg') i += 1 driver.quit() # 끝나면 닫아주기
import dload from bs4 import BeautifulSoup from selenium import webdriver import time driver = webdriver.Chrome('chromedriver') driver.get( "https://search.daum.net/search?nil_suggest=btn&w=img&DA=SBC&q=%EC%A0%95%EA%B5%AD" ) # 여기에 URL을 넣어주세요 time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select('#imgList > div > a > img') i = 1 for thumbnail in thumbnails: src = thumbnail['src'] dload.save(src, f'imgs_homework/{i}.jpg') i += 1 driver.quit() # 끝나면 닫아주기
img.save(f'./imgs_homework/{i}.jpg') #selenium의 webdriver를 쓰려면 브라우저에 맞는 드라이버를 이 코드의 파일과 같은 위치에 설치해야 한다. #크롬의 경우, 크롬드라이버 설치 driver = webdriver.Chrome('chromedriver') driver.get("https://www.google.com/search?q=%EC%83%81%EA%B7%BC%EC%9D%B4&hl=en&sxsrf=ALeKk02oPYTjuVXMoR1Mp82WXhWw7V2XWw:1601537412851&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiFm9nk75LsAhVGCqYKHV4MBnEQ_AUoAXoECBEQAw&biw=958&bih=927") time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') i = 1 #스크랩핑할 정보 우클릭 후, copy->copy selector를 통해 경로를 복사해서 select에 붙여 넣으면 해당 태그를 뽑아낸다. #select_one은 하나의 태그, select는 여러개의 태그 images = soup.select('#islrg > div.islrc > div > a.wXeWr.islib.nfEiy.mM5pbd > div.bRMDJf.islir > img') for image in images: if image.has_attr('src'): url = image["src"] else: url = image["data-src"] if url[0:4] == "data": # print('data: ' + url) getI420FromBase64(url, i) else: # print('http: ' + url) dload.save(url, f'./imgs_homework/{i}.jpg') i += 1 driver.quit() # 끝나면 닫아주기
import dload from bs4 import BeautifulSoup from selenium import webdriver import os # Get instagram id URL = input('Instagram URL: ') # Set the web driver file path driver = webdriver.Chrome('./chromedriver') driver.get(URL) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') # Get Image URL from URL imageURL = soup.select_one('div.KL4Bh > img')['src'] dload.save(imageURL, 'img/download2.jpeg')['src'] driver.quit()
# 2020.10.01 from bs4 import BeautifulSoup from selenium import webdriver import time import dload driver = webdriver.Chrome('./chromedriver') driver.get( "https://search.daum.net/search?nil_suggest=btn&w=img&DA=SBC&q=%EB%B0%95%ED%9A%A8%EC%8B%A0+%EC%BD%98%EC%84%9C%ED%8A%B8" ) # 여기에 URL을 넣어주세요 time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') ################################### # 이제 여기에 코딩을 하면 됩니다! thumbnails = soup.select("#imgList > div > a > img") i = 1 for thumbnail in thumbnails: src = thumbnail["src"] dload.save(src, f'img_homework/박효신_{i}.jpg') i += 1 ################################### driver.quit() # 끝나면 닫아주기
from bs4 import BeautifulSoup from selenium import webdriver import time import dload driver = webdriver.Chrome('./chromedriver') driver.get( "https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%EC%95%84%EC%9D%B4%EC%A6%88%EC%9B%90%20%EA%B9%80%EC%B1%84%EC%9B%90" ) # 여기에 URL을 넣어주세요 time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select("#imgList > div > a > img") i = 0 for thumbnail in thumbnails: img = thumbnail['src'] dload.save(img, f'./img_hw/{i}.jpg') i += 1 driver.quit() # 끝나면 닫아주기
"https://search.naver.com/search.naver?where=image&sm=tab_jum&query=%EC%B9%B4%EB%8B%88%EB%B0%9C+%ED%92%80%EC%B2%B4%EC%9D%B8%EC%A7%80" ) time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source # HTML을 BeautifulSoup이라는 라이브러리를 활용해 검색하기 용이한 상태로 만듦 # soup이라는 변수에 "파싱 용이해진 html"이 담긴 상태가 됨 # 이제 코딩을 통해 필요한 부분을 추출하면 된다. soup = BeautifulSoup(req, 'html.parser') #select_one #select ##_sau_imageTab > div.photowall._photoGridWrapper > div.photo_grid._box > div:nth-child(2) > a.thumb._thumb > img #thumnnails = soup.select('##_sau_imageTab > div.photowall._photoGridWrapper > div.photo_grid._box > div > a.thumb._thumb > img') #img 테크 전체 """ thumnnails = soup.select_one('#_sau_imageTab > div.photowall._photoGridWrapper > div.photo_grid._box > div:nth-child(1) > a.thumb._thumb > img')['src'] print(thumnnails) """ thumnnails = soup.select( '#_sau_imageTab > div > div > div > a > img') #img 테크 전체 i = 1 for thumnnail in thumnnails: image_URL = thumnnail['src'] print(image_URL) dload.save(image_URL, f'car_img/{i}.jpg') #폴더가 경로에 위치 해야 함 i += 1 driver.quit() # 끝나면 닫아주기
from bs4 import BeautifulSoup from selenium import webdriver import time import dload driver = webdriver.Chrome('chromedriver') # 웹드라이버 파일의 경로 driver.get( "https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=eternal%20sunshine" ) time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select("#imgList > div > a > img") i = 1 for thumbnail in thumbnails[:20]: src = thumbnail["src"] dload.save(src, "movies/{}.jpg".format(i)) i += 1 driver.quit()
''' 라이브러리 dload 사용 이미지를 자동으로 다운로드 해주는 라이브러리 이며, 설치 방법은 "file-settings-project-python interpreter-(우측+버튼)-dload" 추가 ''' import dload # 구글의 추석 이미지를 검색한 것을 받아와본다 dload.save( "https://upload.wikimedia.org/wikipedia/commons/4/43/Korean_ancestor_veneration-Jesa-01.jpg" )
# # https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%EC%95%84%EC%9D%B4%EC%9C%A0 from bs4 import BeautifulSoup from selenium import webdriver import time import dload driver = webdriver.Chrome('../venv/chromedriver') # 웹드라이버 파일의 경로 driver.get( "https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%EC%95%84%EC%9D%B4%EC%9C%A0" ) time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source # HTML을 BeautifulSoup이라는 라이브러리를 활용해 검색하기 용이한 상태로 만듦 # soup이라는 변수에 "파싱 용이해진 html"이 담긴 상태가 됨 # 이제 코딩을 통해 필요한 부분을 추출하면 된다. soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select("#imgList > div > a > img") i = 1 for thumbnail in thumbnails: thumb = thumbnail['src'] dload.save(thumb, f'img_test/{i}.jpg') i += 1 driver.quit() # 끝나면 닫아주기
) time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source # HTML을 BeautifulSoup이라는 라이브러리를 활용해 검색하기 용이한 상태로 만듦 # soup이라는 변수에 "파싱 용이해진 html"이 담긴 상태가 됨 # 이제 코딩을 통해 필요한 부분을 추출하면 된다. soup = BeautifulSoup(req, 'html.parser') ################################### # 이제 여기에 코딩을 하면 됩니다! # print(soup) # 원하는 elemnt 우클릭 > 검사 클릭하고, 해당 태그에 대해 " copy select " # imgList > div:nth-child(2) > a > img thumbnails = soup.select("#imgList > div > a > img") i = 1 for thumbnail in thumbnails: src = thumbnail["src"] dload.save(src, f'img/{i}.jpg') i += 1 ################################### driver.quit() # 끝나면 브라우저 닫아주기 ## 1일차 숙제 ## 아이유가 아닌 다른 연예인의 이미지 크롤링하여 저장
time.sleep(5) # 5초 동안 페이지 로딩 기다리기 # 페이지에서 받아온 것들을 req에 저장해서 req = driver.page_source # HTML을 BeautifulSoup이라는 라이브러리를 활용해 검색하기 용이한 상태로 만듦 # soup이라는 변수에 "파싱 용이해진 html"이 담긴 상태가 됨 # 이제 코딩을 통해 필요한 부분을 추출하면 된다. # req를 bs에 넣고! 이제 내가 원하는 부분만 속아 내는 것이여! soup = BeautifulSoup(req, 'html.parser') ## bs를 사용하는 방법은 크게 2가지만 기억하자 # select와 select_one! ################################### # '이미지검사 해서 Copy selector로 복사한 부분' 카피셀럭터로 속아낸다!!!! # 한가지 이미지 src 뽑기 # thumnails = soup.select_one('#imgList > div:nth-child(1) > a > img')['src'] # 해당 코드를 들고온다! [src] 우리는 src값이 필요한데 여기서 볼 수 있다. # 검색한 이미지들이 "nth-child(1)" 이 부분만 달라 ## 여러가지 이미지 src 뽑기 i = 1 thumnails = soup.select('#imgList > div > a > img') for thumnail in thumnails: img = thumnail['src'] dload.save(img, f'img/{i}.jpg') #이미지를 저장하는데, img 폴더에, 1.jpg 라고 저장할꺼야 i += 1 ################################### driver.quit() # 끝나면 닫아주기
import dload from bs4 import BeautifulSoup from selenium import webdriver driver = webdriver.Chrome('chromedriver') driver.get("https://www.starbucks.co.kr/menu/drink_list.do") soup = BeautifulSoup(driver.page_source, 'html.parser') menuDrinks = soup.select('#container .product_list li a > img') # i = 1 for menuDrink in menuDrinks: # print(f'{i}', menuDrink['alt'], menuDrink['src']) # i += 1 dload.save(menuDrink['src'], f"imgs/product/{menuDrink['alt']}.jpg") driver.quit()
import dload from bs4 import BeautifulSoup from selenium import webdriver import time driver = webdriver.Chrome('chromedriver') # driver로 chromedriver 파일 로딩 driver.get("https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%ED%98%84%EB%B9%88") time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') i = 1 thumnails = soup.select('#imgList > div > a > img') for thum in thumnails: img = thum['src'] dload.save(img, f'img2/{i}.jpg') #앞에 img는 받는 변수고, 뒤에 저장할 폴더가 들어감 i += 1 driver.quit()
# 이제 코딩을 통해 필요한 부분을 추출하면 된다. soup = BeautifulSoup(req, 'html.parser') ################################### # print(soup) # 기억할 것 # 1. select # 2. select_one # 해당하는 이미지에 대한 코드로 가서 src만 가져오기! thumbnails = soup.select_one('#imgList > div:nth-child(1) > a > img')['src'] print(thumbnails) # 다른 이미지의 copy selector : #imgList > div:nth-child(2) > a > img # nth-child(2) 이것만 다른 걸 볼 수 있음 # 이미지 여러개 가져오기 # thumbnails_1 = soup.select('#imgList > div > a > img')['src'] thumbnails_1 = soup.select('#imgList > div > a > img') # 이미지 값만 프린트 및 저장 i = 1 for thumbnail in thumbnails_1: img = thumbnail['src'] print(img) dload.save(img, f'img/{i}.jpg') i += 1 ################################### driver.quit() # 끝나면 닫아주기
# import dload # dload.save("https://spartacodingclub.kr/static/css/images/ogimage.png") # import math # print(math.pi) # import 하는 모듈과 실행시키는 파일(*.py)의 파일명을 같게 하면 Error가 발생한다 (= dload.py 라고 만들었어서 오류가 계속 발생했음) # reference : https://brunch.co.kr/@princox/209 import dload dload.save("https://thumbs.gfycat.com/SharpIdolizedAidi-size_restricted.gif", "spart.gif")
import dload from bs4 import BeautifulSoup from selenium import webdriver import time driver = webdriver.Chrome('chromedriver') # 웹드라이버 파일의 경로 driver.get( "https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%EC%A0%9C%EB%8B%88" ) time.sleep(5) # 5초 동안 페이지 로딩 기다리기 req = driver.page_source soup = BeautifulSoup(req, 'html.parser') thumbnails = soup.select('#imgList > div > a > img') i = 1 for thumbnail in thumbnails: img = thumbnail['src'] dload.save(img, f'imgs_homework/{i}.jpg') i += 1 driver.quit() # 끝나면 닫아주기
import dload from bs4 import BeautifulSoup from selenium import webdriver import time driver = webdriver.Chrome('./chromedriver') driver.get( "https://search.daum.net/search?w=img&nil_search=btn&DA=NTB&enc=utf8&q=%ED%83%9C%EB%AF%BC" ) time.sleep(5) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') ################################### taemin_imgs = soup.select('#imgList > div > a > img') i = 0 for taemin_img in taemin_imgs: real_img = taemin_img['src'] dload.save(real_img, f'taemin_img/{i}.jpg') i += 1 ################################### driver.quit() # 끝나면 닫아주기