Bottom Page

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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Scraping data from ebay seller page yuvalta 3 2,422 Sep-25-2019, 04:22 AM
Last Post: sandramoraes
  Scraping data saving to DB error with Cursor cubangt 3 411 May-20-2019, 08:30 PM
Last Post: Yoriz
  Web Scraping and data collection. LordDeanUK 5 1,282 Feb-08-2018, 05:39 PM
Last Post: andrew23
  Scraping data from a web page where same class name applied multiple times sumandas89 1 5,394 Dec-30-2017, 11:03 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)