unable to scrape the current stock price from yahoo finance website using scrapy

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



unable to scrape the current stock price from yahoo finance website using scrapy



I want to scrape the Current Stock Value of any company using scrapy whenever I run the spider from the below Yahoo Finance :


scrapy


spider



But i am unable to extract it using scrapy shell as shown in screenshots.



Screenshot of yahoo finance with red rectangles(details need to be scraped) :








1 Answer
1



If you can't find an element that is supposed to be in a page, I suggest you use view(response). It shows you how the scrapy see the page.
In this case, if you use it by yourself, you can see that in fetched HTML, there is no price element. I set a normal user agent in the request and it worked properly


view(response)


request=scrapy.Request('https://in.finance.yahoo.com/quote/ZUO/key-statistics?p=ZUO', headers='User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0')
fetch(request)
response.xpath('//*[@id="quote-header-info"]/div[3]/div/div/span[1]').extract()



Result:


[u'<span class="Trsdu(0.3s) Fw(b) Fz(36px) Mb(-4px) D(ib)" data-reactid="35">27.40</span>']






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered