From fbefe3d762ceb63514e22918aabfb8845b18fe2f Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 7 Aug 2016 22:01:34 -0400 Subject: [PATCH] URL encode? --- metrik/tasks/bloomberg.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/metrik/tasks/bloomberg.py b/metrik/tasks/bloomberg.py index 970ac93..e11910f 100644 --- a/metrik/tasks/bloomberg.py +++ b/metrik/tasks/bloomberg.py @@ -1,5 +1,6 @@ from luigi import Task, Parameter from pyquery import PyQuery as pq +from urllib.parse import quote_plus import logging @@ -9,10 +10,10 @@ class BloombergEquityInfo(Task): @staticmethod def retrieve_info(bbg_code, user_agent): - url = 'http://www.bloomberg.com/quote/{}'.format(bbg_code) + url = 'http://www.bloomberg.com/quote/{}'.format( + quote_plus(bbg_code)) logging.info('Visiting "{}" with agent "{}'.format(url, user_agent)) - html = pq('http://www.bloomberg.com/quote/{}'.format(bbg_code), - {'User-Agent': user_agent}) + html = pq(url, {'User-Agent': user_agent}) sector, industry, sub_industry = ( html("div.cell:nth-child(13) > div:nth-child(2)").text(),