1
0
mirror of https://github.com/bspeice/metrik synced 2024-11-04 22:48:11 -05:00

URL encode?

This commit is contained in:
Bradlee Speice 2016-08-07 22:01:34 -04:00
parent 383b969cbc
commit fbefe3d762

View File

@ -1,5 +1,6 @@
from luigi import Task, Parameter from luigi import Task, Parameter
from pyquery import PyQuery as pq from pyquery import PyQuery as pq
from urllib.parse import quote_plus
import logging import logging
@ -9,10 +10,10 @@ class BloombergEquityInfo(Task):
@staticmethod @staticmethod
def retrieve_info(bbg_code, user_agent): 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)) logging.info('Visiting "{}" with agent "{}'.format(url, user_agent))
html = pq('http://www.bloomberg.com/quote/{}'.format(bbg_code), html = pq(url, {'User-Agent': user_agent})
{'User-Agent': user_agent})
sector, industry, sub_industry = ( sector, industry, sub_industry = (
html("div.cell:nth-child(13) > div:nth-child(2)").text(), html("div.cell:nth-child(13) > div:nth-child(2)").text(),