Skip to main content

Web Scraping using Beautiful Soup (NEPSE LIVE DATA SCRAPING IN PYTHON)

from bs4 import BeautifulSoup
import requests
import csv

source = requests.get("").text
soup = BeautifulSoup(source, 'lxml')

csv_file = open('nepse.csv','w')

csv_writer = csv.writer(csv_file)
csv_writer.writerow(['Symbol''Values''Total Traded amount'])

marquee_tag = soup.find(
    'div'class_="col-xs-10 col-md-10 col-sm-12").marquee.b

for span_tag in marquee_tag('span'):

for img_tag in marquee_tag('img'):

symbol_list = marquee_tag.text.split('( )')

all_symbols = []
short_name = []
per_share_value = []
total_traded_amount = []
a1 = []
a2 = []
a3 = []

for symbol in symbol_list:
    symbol_name = symbol.replace(u'\xa0'u'')

a = len(all_symbols)

for i in range(a):
    a2.append(a1[i].split(' '))

for i in range(len(a1)):
# print(total_traded_amount)


  1. Need some help. How do I append company values ( for ex. 360, 2845) to the url and save each page with the key string ( like ADBL.html, AHPC.html) .

    comp_dict = {'ADBL':'397', 'AHPC':'360', 'AKBSL':'2845', 'AKJCL':'2788', 'AKPL':'2757'}
    comp = comp_dict.values()
    compids = str(comp)

    url = ""

    with urllib.request.urlopen(url + compids) as url:

    out_file = open(compids[key] +".html", "w")



Post a comment

Popular posts from this blog

How to get GitHub Student Pack, Apply now

Git is a version control system. GitHub is a web-based hosting service for version control using git. You can save all the projects on GitHub. GitHub has given some benefits for students. They recently are providing the student development pack for the students to give access to developers tools for free. Some of these real world tools are too expensive for a student to use. So, for those students who love the education, this could be just great! To get students developer pack, we are going to follow these steps:
1. First you need to make an account on GitHub. Go to this link and sign up for free. 2. After making an account on GitHub, visit the link
3. Click on “Get your pack” button.  4.Sign with GitHub with your username and password.  5. Click on the button “Yes, I’m a Student”.
6. Enter your name and verify your academic status. Add a photo of your identity card where it says “Drop file here or click to upload”. 
7. Enter your C…

Basic guidelines for Chess opening.

If you are reading this blog, you probably know how the pieces move in the game of chess. The player with the white pieces always moves first. The opening is generally considered complete when your rooks are connected. There are some basic principles to follow how to play efficiently. We should focus on the development of pieces. Here are top 10 opening rules for good chess opening:
We must attack the center of board. So, OPEN with a CENTER PAWN like e4, d4. While (e4d4e5d5) are generally regarded as the central squares, the same principle can sometimes be extended to the adjacent squares like (c4c5d3d6e3e6f4f5).DEVELOP pieces with threats. Always develop your Knights before Bishops. Develop knights to towards the center of board rather than side of board. When the knight is developed in the center, it could attack up to 8 squares. The real reason to develop Knights before Bishops is that Knight are shorter-range pieces, and it will take them a couple of moves to ge…

Who am I?

Who am I? Am I really the same person a year ago? Are my perceptions changed about people? Don’t I look the world like other people use to see it? Who am I really? A student, a writer? I might. It’s kind of puzzling. Why I find my perceptions being changed for people whom I find very cool a year ago? Who am I when there is nobody to impress?

From my endless talk you might think, I am the most talkative person, or from my level of humor (which most of you don’t get) you might think my talks are very big. Or from my silence (those who don’t know me), you might think I am shy or the meanest or the coldest guy alive. I am none of those!!

Then who am I? Why am I even writing this? Am I writing this for me or for some other person, with hope, s/he will read this someday. Okay! I wrote for you and for me. I’m not writing this to exaggerate my feelings and I’m never been that sort of person. Am I really not seeing the forest for the trees? 

PS: Waiting for Feedback. Thankyou!!