• requests爬虫get请求


    1、简单get请求

    url = 'https://www.baidu.com'
    headers = {
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'zh-CN,zh;q=0.9',
        'upgrade-insecure-requests': '1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
        # 'cookie': 'xxx;yyy;zzz',
        # 'referer': 'https://xxx.yyy.zzz'
    }
    
    # 发起get请求
    response = requests.get(url, headers=headers, verify=True)
    # 获取html文本
    html_data = response.content.decode()
    print(html_data)
    print(len(html_data))
    

      

  • 相关阅读:
    BZOJ-3495 前缀优化建图2-SAT
    洛谷P3979 遥远的国度 树链剖分+分类讨论
    hdu
    hdu
    poj
    poj-1330(暴力写的lca)
    树链剖分
    Dijkstra
    Floyed
    最短路径
  • 原文地址:https://www.cnblogs.com/andy9468/p/11492910.html
Copyright © 2020-2023  润新知