這是我寫的代碼。爲什麼我的抓取工具使用BeautifulSoup,不顯示結果?
import requests
from bs4 import BeautifulSoup
def code_search(max_pages):
page = 1
while page <= max_pages:
url = 'http://kindai.ndl.go.jp/search/searchResult?searchWord=朝鮮&facetOpenedNodeIds=&featureCode=&viewRestrictedList=&pageNo=' + str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, 'html.parser')
for link in soup.findAll('a', {'class': 'item-link'}):
href = link.get('href')
page += 1
code_search(2)
我pycharm版本是pycharm社區-5.0.3的Mac。
它只是說:
"Process finished with exit code 0"
但應該有一定的結果,如果我已經寫的代碼相應...
請幫我在這裏!
首先,在所有的,你忘了'print'。然後,你想得到什麼? –
沒有'return'否'print' ...你怎麼看待輸出? –
你有什麼預期的輸出? –