I save in the project array.
I can not save to .csv , writes writerow() , separated by a comma, there is no content from the project array.
Where can there be a mistake?
def get_parse(html): soup = BS(html, 'lxml') hrefs = soup.find_all('a', class_='address') for inc,aa in enumerate(hrefs, start=1): soup= BS(get_html(aa.get('href')), 'lxml') rot = soup.find_all('a', class_="green dhide") project = [] for ii in rot: namber = ii.text project.append({ 'Modile' : namber }) return (project) def save(project, path): with open(path, 'w') as csvfile: writer = csv.writer(csvfile) writer.writerow(('Namber modile')) for lists in project: writer.writerow(lists['Mobile']) def main(): project = [] for page in range(1, 2): base_url = url + 'page=%d'% page + '&size=10' inc = get_parse(get_html(base_url)) save(project, 'mob_tel.csv') if __name__ == '__main__': main()
правитьbutton). If an error occurred while executing the code, then add its text to the question. Thank. - gil9redproject = []variables, most likely you need to transferproject = []parameter toget_parse, and thatproject = [], which is removed from the function - gil9red