Python Forum
How can automatize ticker selection to find the trading data of all the tickers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can automatize ticker selection to find the trading data of all the tickers
#1
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?

import scrapy


class InsiderSpider(scrapy.Spider):
    name = 'insider'
    allowed_domains = ['www.secform4.com']
    start_urls = ['https://www.secform4.com/insider-trading/320193.htm']

    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)
Reply


Messages In This Thread
How can automatize ticker selection to find the trading data of all the tickers - by nazmulfinance - Nov-12-2019, 06:58 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020