max_chapter
을 설정하고 챕터 번호가 max_chapter
에 도달 할 때까지 기능을 수행하고 싶습니다. 그런 다음 장부 번호가 1 씩 증가하고 장 번호가 max_chapter
에 도달 할 때까지 동일한 기능을 수행합니다.이 경우 두 개의 "while"루프를 함께 넣는 방법은 무엇입니까?
예를 들어 제 1 권 - 제 1 장 ~ 20 장, 제 2 권은 책 2 - 제 1 장 ~ 20 장, ... 등의 기능을합니다.
import requests
from bs4 import BeautifulSoup
import operator
def start(max_book):
word_list = []
book = 1
chapter = 1
while book <= max_book:
url = ('http://www.holybible.or.kr/B_NIV/cgi/bibleftxt.php?VR=NIV&VL='
+ str(book) + '&CN=' + str(chapter) + '&CV=99')
while chapter <= 1:
source_code = requests.get(url).text
soup = BeautifulSoup(source_code, "html.parser")
for bible_text in soup.findAll('font', {'class': 'tk4l'}):
content = bible_text.get_text()
words = content.lower().split()
for each_word in words:
word_list.append(each_word)
chapter += 1
else:
book += 1
print(word_list)
start(1)
당신이 그들을 함께 넣어 무엇을 의미합니까? – Sayse
오 ... 내가 책 1에서 1 장 ~ 20 장까지 모든 텍스트를 훑어보고 책 2의 1 장으로 이동해서 똑같은 일을하고 싶다. 그래서 str (장)과 str (책) 모두 순서대로 증가해야한다고 생각합니다. 아니? –