Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

python - How can I print all pages of an api?

Tryin to run a sentiment analysis on entire dataset, but I can only thumb through one at a time. I have the code for the sentiment analysis, but I can't seem to figure out how to iterate through all pages and print them all to then run the SA. Please see what I have tried below:

Cell 1:

    bitcoin_news = newsapi.get_everything(q="bitcoin", language="en", sort_by="publishedAt", page=99, page_size=100)

Cell 1a (code I've tried):

    def get_and_print_data(bitcoin_news):

            r = bitcoin_news

            for i in r:
            print(i)
            if r.get('next'):
                    get_and_print_data(info['next'])

            return get_and_print_data

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...