Launch HTML code in browser (that is generated by BeautifulSoup) straight from Python

后端 未结 3 656
情深已故
情深已故 2020-12-09 16:16

I have used BeautifulSoup for Python 3.3 to successfully pull desired info from a web page. I have also used BeautifulSoup to generate new HTML code to display this info. Cu

3条回答
  •  感情败类
    2020-12-09 16:30

    Use Flask to turn your code into a local web application:

    from flask import Flask
    app = Flask(__name__)
    
    @app.route('/')
    def scrape_and_reformat():
        # call your scraping code here
        return ' ... generated html string ... '
    
    if __name__ == '__main__':
        app.run()
    

    Run the script, and point your browser at http://127.0.0.1:5000/.

提交回复
热议问题