How to read html from a url in python 3

后端 未结 6 1917
滥情空心
滥情空心 2020-12-08 02:13

I looked at previous similar questions and got only more confused.

In python 3.4, I want to read an html page as a string, given the url.

In perl I do this w

6条回答
  •  广开言路
    2020-12-08 02:24

    Try the 'requests' module, it's much simpler.

    #pip install requests for installation
    
    import requests
    
    url = 'https://www.google.com/'
    r = requests.get(url)
    r.text
    

    more info here > http://docs.python-requests.org/en/master/

提交回复
热议问题