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
  POST request with form data issue web scraping hoff1022 1 499 Aug-14-2020, 10:25 AM
Last Post: kashcode
  Scraping Data issues TrexKikBut 1 1,659 Aug-14-2020, 10:20 AM
Last Post: kashcode
  Scraping a dynamic data-table in python through AJAX request filozofo 1 400 Aug-14-2020, 10:13 AM
Last Post: kashcode
  Web Scraping and data collection. LordDeanUK 6 1,715 Jun-29-2020, 06:04 PM
Last Post: HarleyQuin
  error zomato scraping data syxzetenz 3 1,125 Jun-23-2020, 08:53 PM
Last Post: Gribouillis
  Scraping data from ebay seller page yuvalta 3 3,061 Sep-25-2019, 04:22 AM
Last Post: sandramoraes
  Scraping data saving to DB error with Cursor cubangt 3 676 May-20-2019, 08:30 PM
Last Post: Yoriz
  Scraping data from a web page where same class name applied multiple times sumandas89 1 7,419 Dec-30-2017, 11:03 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)