Python Forum
Web Scraping, Merging two lists and getting data from various dates?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web Scraping, Merging two lists and getting data from various dates?
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to scraping data from dinamic site sergio21124444 2 646 Nov-08-2023, 12:43 PM
Last Post: sergio21124444
  Scraping data from table into existing dataframe vincer58 1 1,960 Jan-09-2022, 05:15 PM
Last Post: vincer58
  Web scraping data Mike_Eddy 2 2,489 Jul-03-2021, 05:49 PM
Last Post: Mike_Eddy
  Scraping lender data from Ren Ren Dai website using Python. I will pay for that 200$ Hafedh_2021 1 2,724 May-18-2021, 08:41 PM
Last Post: snippsat
  Code Help, web scraping non uniform lists(ul) luke_m 4 3,280 Apr-22-2021, 05:16 PM
Last Post: luke_m
  Scraping a page with log in data (security, proxies) iamaghost 0 2,103 Mar-27-2021, 02:56 PM
Last Post: iamaghost
  Scraping Data from Singapore Turf Club singaporeman 2 2,359 Dec-15-2020, 01:28 PM
Last Post: MrBitPythoner
Thumbs Up Issue facing while scraping the data from different websites in single script. Balamani 1 2,076 Oct-20-2020, 09:56 AM
Last Post: Larz60+
  POST request with form data issue web scraping hoff1022 1 2,649 Aug-14-2020, 10:25 AM
Last Post: kashcode
  Scraping Data issues TrexKikBut 1 3,862 Aug-14-2020, 10:20 AM
Last Post: kashcode

Forum Jump:

User Panel Messages

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