trade_url.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:gw_trade 作者: stormtrader 项目源码 文件源码
def get_to_url(self, request_url, get_data):
        if get_data == "":
            tmp_url = request_url
        else:
            tmp_url = request_url + "?" + get_data
        #print tmp_url
        #print self.my_cookie
        req = urllib.request.Request(
            url=request_url,
            )
        req.add_header('Cookie', self.my_cookie)
        #print req.headers
        #print req.data
        try:
            resp = urllib.request.urlopen(req, timeout=3)
        except urllib.HTTPError as e:
            logging.warn("server process request error: err_code=%s", e.code)
            return -5, None
        except urllib.URLError as e:
            logging.warn("reach server error: reason=%s", e.reason)
            return -10, None
        except Exception as e:
            logging.warn("other exception: msg=%s", e.message)
            return -100, None

        htm = resp.read()
        return 0, htm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号