how to open a url in python

后端 未结 7 1793
夕颜
夕颜 2020-12-22 19:01
import urllib

fun open():
    return urllib.urlopen(\'http://example.com\')

But when example.com opens it does not render css or js. How can I ope

相关标签:
7条回答
  • 2020-12-22 19:54

    You have to read the data too.

    Check out : http://www.doughellmann.com/PyMOTW/urllib2/ to understand it.

    response = urllib2.urlopen(..)
    headers = response.info()
    data = response.read()
    

    Of course, what you want is to render it in browser and aaronasterling's answer is what you want.

    0 讨论(0)
提交回复
热议问题