【Python爬虫】- #13 requests模块练习

import requests

url = 'http://www.ygdy8.com/'

headers = {

  'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',

'Accept-Encoding':'gzip, deflate',

'Accept-Language':'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4',

'Cache-Control':'max-age=0',

'Connection':'keep-alive',

'Cookie':'37cs_pidx=1; 37cs_user=37cs78691413268; 37cs_show=69; UM_distinctid=15e36b74d82561-042fa83480e0e9-8383667-1fa400-15e36b74d836c6; CNZZDATA5783118=cnzz_eid%3D1135589022-1504151834-%26ntime%3D1504151834; cscpvrich4016_fidx=3',

'Host':'www.ygdy8.com',

'If-Modified-Since':'Wed, 30 Aug 2017 14:38:20 GMT',

'If-None-Match':'"056e49f9d21d31:530"',

'Upgrade-Insecure-Requests':'1',

'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'

}

req = requests.get(url)

status_code = req.status_code

print(status_code)

req.encoding = 'gb2312'

html = req.text

movie_html = html

print(movie_html)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容