Get html using Python requests?

后端 未结 2 1964
情歌与酒
情歌与酒 2020-12-03 09:47

I am trying to teach myself some basic web scraping. Using Python\'s requests module, I was able to grab html for various websites until I tried this:

>&         


        
2条回答
  •  独厮守ぢ
    2020-12-03 10:46

    The HTTP headers for this URL have now been fixed.

    >>> import requests
    >>> print requests.__version__
    2.5.1
    >>> r = requests.get('http://www.wrcc.dri.edu/WRCCWrappers.py?sodxtrmts+028815+por+por+pcpn+none+mave+5+01+F')
    >>> r.text[:100]
    u'\n\n\nMonthly Average of Precipitation, Station id: 028815>> r.headers
    {'content-length': '3672', 'content-encoding': 'gzip', 'vary': 'Accept-Encoding', 'keep-alive': 'timeout=5, max=100', 'server': 'Apache', 'connection': 'Keep-Alive', 'date': 'Thu, 12 Feb 2015 18:59:37 GMT', 'content-type': 'text/html; charset=utf-8'}
    

提交回复
热议问题