import requests from bs4 import BeautifulSoup import csv def main(): pattern = 'https://forum.dirt.ru/member.php?u={}' for i in range(0, 76128): url = pattern.format(str(i)) get_html(url) def get_html(url): rs = requests.get(url) root = BeautifulSoup(rs.content, 'html.parser') nickname = root.select_one('.bigusername').text.strip() data = { 'nickname': nickname} write_csv(data) def write_csv(data): with open('nickname.csv', 'a') as f: writer = csv.writer(f) writer.writerow((data['nickname'])) if __name__ == '__main__': main() Why does it return null and not create a csv file?
def get_html():error - nourlparameter. Is this the code that you use or when composing the question sealed? - gil9redправитьbutton) Checked what is indata? - gil9redif __name__ == '__main__':main(), otherwise your code is not executed - gil9redroot.select_one('.bigusername').returned None, i.e. That nickname was not found at boot. Vanguyu that, in his own cycle, you staged a dos attack on the site and at some iteration he returned the stub, for example with a captcha - gil9red.textto write brackets - this is not a function - gil9red