Nov-12-2019, 06:58 PM
(This post was last modified: Nov-12-2019, 06:59 PM by nazmulfinance.)
Dear Members,
I am trying to download data in Table 1 from https://www.secform4.com/insider-trading
I need to put Company Ticker to get information about the specific company. Say, I want data about Apple Inc. (Ticker=AAPL). I get the following page: https://www.secform4.com/insider-trading/320193.htm. My objective here is to extract table 1 data from all the years for all the stocks including AAPL. Is there any way I can command python to find Company Ticker from a particular file saved on my PC?
I am trying to download data in Table 1 from https://www.secform4.com/insider-trading
I need to put Company Ticker to get information about the specific company. Say, I want data about Apple Inc. (Ticker=AAPL). I get the following page: https://www.secform4.com/insider-trading/320193.htm. My objective here is to extract table 1 data from all the years for all the stocks including AAPL. Is there any way I can command python to find Company Ticker from a particular file saved on my PC?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import scrapy class InsiderSpider(scrapy.Spider): name = 'insider' allowed_domains = [ 'www.secform4.com' ] def parse( self , response): insiders = response.xpath( "(//table[@class='sort-table'])[1]/tbody/tr" ) for insider in insiders: transaction_date = insider.xpath( ".//td[@class='S']/text()[position()=1]" ).get() buy_sale = insider.xpath( ".//td[@class='S']/text()[position()=2]" ).get() yield { 'transaction_date' : transaction_date, 'buy_sale' : buy_sale } next_page = response.xpath( "(//div/font/a[11]/@href)[1]" ).get() if next_page: yield scrapy.Request(url = next_page, callback = self .parse) |