新闻  |   论坛  |   博客  |   在线研讨会
冬奥“手办”冰墩墩如何抢购
laical | 2022-02-08 15:22:54    阅读:110   发布文章

       在本届北京冬奥会上,吉祥物“冰墩墩“是当仁不让的最红“手办”,众多国外媒体和选手被冰墩墩憨态可爱的形象吸引迅速圈粉,其中日本记者辻岡义堂在赛事还未正式揭幕时,直接购买了6个冰墩墩娃娃,通过电视直播毫不掩饰的进行了炫耀,一些选手也会把冰墩墩摆在身旁一同入睡。

       冬奥特许商品生产商元隆雅图也在加紧生产,但是要做到“一户一墩”还是不太可能的,大家可以通过下面的爬虫程序参考修改,随时关注“奥林匹克官方旗舰店”一旦有货即可下单。

       demo是Python基于scrapy 框架通过HTTPS会话指定IP实现,新建文件 (./项目名/tunnel_fix.py) 在项目文件最开始位置from . import tunnel_fix :

    from scrapy.utils.python import to_bytes, to_unicode
    import scrapy.core.downloader.handlers.http11
    from random import randint

    def tunnel_request_data(host, port, proxy_auth_header=None):
        host_value = to_bytes(host, encoding='ascii') + b':' + to_bytes(str(port))
        tunnel_req = b'CONNECT ' + host_value + b' HTTP/1.1\r\n'
        tunnel_req += b'Host: ' + host_value + b'\r\n'
        if proxy_auth_header:
            tunnel_req += b'Proxy-Authorization: ' + proxy_auth_header + b'\r\n'
            # 指定Proxy-Tunnel
            proxy_tunnel = '{}'.format(randint(1,9999))
            tunnel_req += b'Proxy-Tunnel: '+ to_bytes(proxy_tunnel)  + b'\r\n'
        tunnel_req += b'\r\n'
        return tunnel_req

    scrapy.core.downloader.handlers.http11.tunnel_request_data = tunnel_request_data


*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客