def getData(base_url,num):
html = askUrl(base_url)
soup = BeautifulSoup(html,'html.parser')
count = num
data = []
for addr in soup.find_all('div',class_='imgbox'): #
askUrl(base_url)正常返回的是网页html代码,但是在循环中打印addr就显示不出来,应该是没进入循环体,求大佬告知为啥没进入循环
估计是soup.find_all('div',class_='imgbox')没有返回值。从这几个方面排查修改:检查所写节点是否正确,根据页面代码进行修改; html应该是文本格式,即在askUrl中返回的是html.text;在soup中改用其他解析器,如'lxml’,'html5lib'
你debug看看soup.find_all('div',class_='imgbox')有没有返回数据?