defdownload(content,page): tree=etree.HTML(content) # nickname_list=tree.xpath('//div[@class="content"]/p/@nick-name') content_list=tree.xpath('//div[@class="content"]/p/text()') book = Workbook() sheet = book.active filename=str(page)+"weibo.xlsx" for i in (range(1,len(content_list))): nickname_row='A'+str(i) sheet[nickname_row]=content_list[i] book.save(filename) if __name__=='__main__': start_page=int(input('please enter the start page:')) end_page=int(input('please enter the end page:')) for page inrange(start_page,end_page+1): request=topic_create_request(page) content=topic_get_content(request) download(content,page)