cat_list = ['008']
book_num = list(range(20))
page_num = list(range(1,10))
b_title = []
driver = webdriver.Chrome('~')
for c in cat_list:
url = 'http://www.yes24.com/24/Category/Display/001001016003'+ str(c) + '?ParamSortTp=04'
for p in page_num:
driver.get(url + '&PageNumber=' + str(p))
time.sleep(1)
for n in book_num:
first_img = driver.find_elements_by_class_name('goods_imgSet')
first_img[n].click()
time.sleep(1)
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
book_pdate = soup.find('span', {'class': 'gd_date'})
book_pyear = book_pdate.text
if str(2020) in book_pyear:
book_title = soup.find('h2', {'class': 'gd_name'})
print(book_title.text)
b_title.append(book_title.text)
book_img = soup.find_all('em', {'class': 'imgBdr'})
img_url = book_img[0].find('img')['src']
img_url = img_url + '.jpg'
print(img_url)
urllib.request.urlretrieve((img_url, img_url.find('img')['src'] + "jpg"))
else:
break
driver.back()
I tried to bring pictures of each book after accessing page url through the list.
I can bring image url but I have a problem saving the file.
The error is as follows TypeError: expected string or bytes-like object
How can I save the image?