import urllib.request
import urllib.parse
# query_url에 원하는 웹의 URL을 넣어주시면 됩니다.
query_url='https://www.amazon.com/bestsellers?ld=NSGoogle'
res=urllib.request.urlopen(query_url)
html = res.read()
soup = BeautifulSoup(html, 'html.parser')
result = soup.find('ul', id='zg_browseRoot').find('ul')
slist = result.find_all('li')
sec_list=[]
count=1
for li in slist:
sec = li.get_text()
sec_list.append(str(count)+"."+sec)
count+=1
cnt=1
sec_input=[]
for i in sec_list:
sec_input.append(i+'\t')
if (cnt%3)==0:
sec_input.append('\n')
cnt+=1
sec_input.append('\n\n'+'1.위 분야 중에서 자료를 수집할 분야의 번호를 선택하세요: ')
sec=input(str(''.join(sec_input)))
'컴퓨터 > Python' 카테고리의 다른 글
python pyside2 qtdesigner 설치 (0) | 2020.10.19 |
---|---|
python pyside2 파이썬클래스 box layout (0) | 2020.10.18 |
python tqdm 진행률 (0) | 2020.10.16 |
python 폴더내 txt파일 합쳐서 xlsx로 저장하기 (0) | 2020.10.13 |
python windows 이용 alert 창 띄우기 (0) | 2020.10.13 |