from time import sleep
from urllib import request
from bs4 import BeautifulSoup
categories = ['domestic', 'world', 'economy', 'entertainment', 'sports',
    'computer', 'science', 'local']
for category in categories:
    print('category:', category)
    with open('%s.txt' % category, 'w') as f:
        for page in range(50):
            html = request.urlopen(
                'https://news.yahoo.co.jp/list/?c=%s&p=%s' % (category, page)
                ).read()
            soup = BeautifulSoup(html, 'html.parser')
            for ttl in soup.select('.listArea .list li .ttl'):
                f.write(ttl.string + '\n')
                print('ttl:', ttl.string)
            sleep(1)

f22ab5b094b833cd18504e2ea9e4739afaffcee1
<mask token>

<mask token>
for category in categories:
    print('category:', category)
    with open('%s.txt' % category, 'w') as f:
        for page in range(50):
            html = request.urlopen(
                'https://news.yahoo.co.jp/list/?c=%s&p=%s' % (category, page)
                ).read()
            soup = BeautifulSoup(html, 'html.parser')
            for ttl in soup.select('.listArea .list li .ttl'):
                f.write(ttl.string + '\n')
                print('ttl:', ttl.string)
            sleep(1)

<mask token>
categories = ['domestic', 'world', 'economy', 'entertainment', 'sports',
    'computer', 'science', 'local']
for category in categories:
    print('category:', category)
    with open('%s.txt' % category, 'w') as f:
        for page in range(50):
            html = request.urlopen(
                'https://news.yahoo.co.jp/list/?c=%s&p=%s' % (category, page)
                ).read()
            soup = BeautifulSoup(html, 'html.parser')
            for ttl in soup.select('.listArea .list li .ttl'):
                f.write(ttl.string + '\n')
                print('ttl:', ttl.string)
            sleep(1)

from time import sleep
from urllib import request
from bs4 import BeautifulSoup
categories = ['domestic', 'world', 'economy', 'entertainment', 'sports',
    'computer', 'science', 'local']
for category in categories:
    print('category:', category)
    with open('%s.txt' % category, 'w') as f:
        for page in range(50):
            html = request.urlopen(
                'https://news.yahoo.co.jp/list/?c=%s&p=%s' % (category, page)
                ).read()
            soup = BeautifulSoup(html, 'html.parser')
            for ttl in soup.select('.listArea .list li .ttl'):
                f.write(ttl.string + '\n')
                print('ttl:', ttl.string)
            sleep(1)
