Python Forum
Web Scraping, Merging two lists and getting data from various dates? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Web Scraping, Merging two lists and getting data from various dates? (/thread-24286.html)



Web Scraping, Merging two lists and getting data from various dates? - AgileAVS - Feb-07-2020

import urllib.request, urllib.parse, urllib.error
import re
import requests
from bs4 import BeautifulSoup

fhand = urllib.request.urlopen('https://www.sharesansar.com/today-share-price')
html = fhand

soup = BeautifulSoup(html, 'lxml')

for td_tag1 in soup.select('td:nth-child(2)'):
    data2=td_tag1.text
    print('Company Name:',data2)

for td_tag1 in soup.select('td:nth-child(7)'):
    data7=td_tag1.text
    print('Closing Price:',data7)
Hello guys, I am fairly new to python and this is the code that I have written to extract related to stock market from the website:https://www.sharesansar.com/today-share-price for which I have already taken their permission.

The above code prints the company name and closing price separately. So here are my challenges.
1. How do I combine these in a way that the company name would be listed or joint together with its respective closing price?
2. There are various prices such as for example price for today or from yesterday. I did some google on the topic and I found out that it could be done through DATES? Like, there is a calendar in their website through which we can extract data from various dates, but how do I do it?

Regards,
Aabhash Shrestha
Thank you for your constant help guys and sorry if I have maybe failed to comply with the forum's code, which I failed in the last thread. Anyways, a big thank you for helping new people like us learn and code better, this forum and you guys have been true blessings.