1+ # -*- coding: utf-8 -*-
2+ """
3+ Created on Tue Sep 24 14:31:25 2019
4+
5+ @author: rayde
6+ """
7+ from finance_python import stock
8+ import requests , pandas , lxml
9+ from bs4 import BeautifulSoup as soup
10+ from urllib .request import urlopen
11+ from lxml import html
12+
13+ class mj (stock ):
14+ def __init__ (self , weed_stocks , links ):
15+ self .attributes = [ ]
16+ self .stocks = list (zip (weed_stocks , links ))
17+ #self.soup = soup()
18+
19+ def __general__ (self , url ):
20+ Client = urlopen (url )
21+ xml_page = Client .read ()
22+ Client .close ()
23+ soup_page = soup (xml_page ,"xml" )
24+ return soup_page
25+
26+ def __table__ (self , url ):
27+ page = requests .get (url )
28+ tree = html .fromstring (page .content )
29+ table = tree .xpath ('//table' )
30+ table = list (map (lambda x : pandas .read_html (lxml .etree .tostring (table [x ], method = 'xml' ))[0 ], range (0 ,len (table ))))
31+ return table
32+
33+ def sales_growth (self ):
34+ sales_growth = []
35+ return sales_growth
36+
37+ def production_costs (self ):
38+ cost_of_production = []
39+ return cost_of_production
40+
41+ def cost_sold (self ):
42+ cost_of_goods_sold = []
43+ return cost_of_goods_sold
44+
45+ def soup (self ):
46+ soup_page = list (map (lambda x : self .__general__ (x [1 ]), self .stocks ))
47+ return soup_page
48+
49+ def items (self , soup_page ):
50+ item_list = soup_page .find_all ('item' )
51+ return item_list
52+
53+ def links (self , soup_page ):
54+ links_list = soup_page .find_all ('link' )
55+ return links_list
56+
57+ def titles (self , soup_page ):
58+ titles = soup_page .find_all ('title' )
59+ return titles
60+
61+ def description (self , soup_page ):
62+ descriptions = soup_page .find_all ('description' )
63+ return descriptions
64+
65+ def subject (self , soup_page ):
66+ subject = soup_page .find_all ('subject' )
67+ return subject
68+
69+ if __name__ == '__main__' :
70+ weed_stocks = ['CRON.TO' , 'FIRE.TO' , 'ACB.TO' ,
71+ 'VFF.TO' , 'APHA.TO' , 'WEED.TO' , 'TGOD.TO' ]
72+
73+ links = ['https://www.globenewswire.com/RssFeed/Organization/n40N3EwqUdtaSsRfodARTg==' ,
74+ 'https://www.prnewswire.com/news-releases/supreme-cannabis-announces-q4-and-2019-fiscal-year-end-financial-results-300920109.html' ,
75+ "https://www.prnewswire.com/news-releases/aurora-cannabis-announces-financial-results-for-the-fourth-quarter-and-2019-fiscal-year-300916447.html" ,
76+ 'https://www.globenewswire.com/RssFeed/Organization/JDHyurLpImZNh2UX9_Ud2g==' ,
77+ 'https://www.globenewswire.com/RssFeed/Organization/R1h25zYnVjsHP2c9g1rymw==' ,
78+ 'https://www.prnewswire.com/news-releases/canopy-growth-drives-revenue-with-94-increase-in-recreational-dried-cannabis-sales-in-first-quarter-of-fiscal-2020-300901964.html' ,
79+ 'https://www.globenewswire.com/RssFeed/Organization/hp_wl2JXUNsysLV7iSAl9A==' ]
80+
81+ acb_data = [{'rev_change' :.61 }, {'revenue' :94.6 }, {'production_cost' : 1.14 },
82+ {'volume' : 29034 }, {'volume_chg' : .86 }, {'gross margin' : .58 },
83+ {'medical patients' : 89700 }]
84+
85+ cgc_data = [{'rev_change' : - .038 }, {'revenue' :90.5 }, {'production_cost' : },
86+ {'volume' : 10 ,549 }, {'volume_chg' : .13 }, {'gross margin' : .43 }]
0 commit comments