Last active
November 24, 2017 05:35
-
-
Save osori/f8b6a0e5339606f4f3795861eaad1572 to your computer and use it in GitHub Desktop.
pangyo-hyundai
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
# Jupyter Notebook에서 실행하세요 | |
from IPython.display import Image, display | |
from bs4 import BeautifulSoup | |
import requests | |
print("어서오세요 품격과 전통의 판교 현백입니다.\n 어떤 물건을 찾으세요?") | |
query = input() # 유저 인풋 받아오기 | |
response = requests.get("http://www.thehyundai.com/front/dpo/hdSearch.thd?searchtype=&" + | |
"searchQuery=" + query) | |
soup = BeautifulSoup(response.text, 'html.parser') | |
products = soup.select('#product-list li .prod-unit') | |
for idx, product in enumerate(products): | |
img_url = product.find('img')['src'] | |
price = product.find('div', class_='price-info').text.strip().splitlines()[0] | |
name = product.find('a', class_='title ellipsis').text | |
print(f'{idx}. {name}') | |
display(Image(url=img_url)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment