<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by vaddamani prasanna on Medium]]></title>
        <description><![CDATA[Stories by vaddamani prasanna on Medium]]></description>
        <link>https://medium.com/@vaddamani.prasanna?source=rss-4cd156332bfe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yqygIfYIAL33uMGI</url>
            <title>Stories by vaddamani prasanna on Medium</title>
            <link>https://medium.com/@vaddamani.prasanna?source=rss-4cd156332bfe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 22:35:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vaddamani.prasanna/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Web-Scraping with Visualization and Analysis in Python]]></title>
            <link>https://medium.com/@vaddamani.prasanna/web-scraping-with-visualization-and-analysis-in-python-6259b31b51b5?source=rss-4cd156332bfe------2</link>
            <guid isPermaLink="false">https://medium.com/p/6259b31b51b5</guid>
            <dc:creator><![CDATA[vaddamani prasanna]]></dc:creator>
            <pubDate>Fri, 31 Jul 2020 06:55:47 GMT</pubDate>
            <atom:updated>2020-07-31T06:55:47.775Z</atom:updated>
            <content:encoded><![CDATA[<h3>Up-Skilling myself in Data Science course and here is my first blog on the Web Scraping.</h3><h3>Problem Statement: Scrape any of the product of your choice, clean the data, generate the visualizations which helps to analyse and take the decision for purchase within the budget.</h3><h3>Let us understand what is Web Scraping:</h3><p>Web Scraping is also called as Web Crawling, Screen Scraping, Web Data Extraction, Web Harvesting etc., It is the process of retrieving or “scraping” unstructured data from websites. It uses intelligent automation to retrieve hundreds, millions, or even billions of data points from the websites and helps you to ease in your analysis.</p><p>For example: If you want to purchase any mobile within your budget, you search for the mobiles in the shopping sites like Flipkart, Snapdeal etc., Copy and paste the data manually in the excel sheet and analyse for decision making.</p><p>With the help of Web Scraping, you can extract the data automatically in fraction of seconds from unstructured format to the structured format which helps you to do the analysis and take decisions within time.</p><h3>Parts of Web Scraping:</h3><p>Web Scraping has 2 parts: 1. Web Crawler which helps you to move/navigate as per your instructions to search the data. 2. Scraper which helps you to copy/extract the data from Websites.</p><h3>How it Web Scraping works:</h3><p>It works like a BOT which does all the activities on behalf of Human in searching the products in the website, crawls all the pages by extracting the unstructured data in to the format you would like to have like DataFrames, Excel sheet, CSV file etc for future purpose.</p><p>Multiple libraries used in data extraction like Scrappy, Beautiful Soup etc. Most frequently used library is Beautiful Soup. I will be using the same. Here is more in detail about.</p><h3>Beautiful Soup:</h3><p>Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work.</p><p>I have considered to search for Mobiles from FlipKart website and here is the steps for the same:</p><p>Steps used in scraping the data from the Website:</p><ol><li>Find the URL(site) in which you would like to search</li><li>Inspect/Crawl page by page in the Web Site.</li><li>Right click on the page and click on Inspect which helps you to see the code used for displaying the mobile data in the Flipkart site. Entire code is written in HTML and you need to have basic understanding on the HTML to read the code.</li><li>Create BeautifulSoup object by parsing the html to it which helps you to navigate to the HTML tags in that page.</li><li>Use findAll function with BeautifulSoup object to locate the “div” tags in the HTML page which contains has all the features of the mobiles within. This acts as a container.</li><li>Now locate the feature by using find function by passing the class name of the tag and save them in the respective variables.</li><li>Extract all the values and store them in them the arrays.</li><li>Create a data-frame for storing the scrapped data for future analysis.</li></ol><h3>Web Scraping with Analysis in Python</h3><h3>Import all the python packages required</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/0*hZXZK-o7I1l7cceB" /></figure><h3>Give the input of the product you are looking for along with the Budget range</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*ZlPGSM8SkPFqXOIp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*CuJZyiF7sJXyT4bn" /></figure><h3>Now, lets create the lists for storing the product and its features along with the dataframe to store the entire data extract from unstructured format to structured format.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/0*fZOdgUZk4vJyvhGa" /></figure><h3>Create user agent below,For reference <a href="https://pypi.org/project/fake-useragent/">https://pypi.org/project/fake-useragent/</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/0*Pury0RbDsmeLoHE9" /></figure><h3>Extract data from multiple pages of the product listing we’re going to use a for loop. The range will specify the number of pages to be extracted. The data that we extract is unstructured data. So we’ll create empty lists to store them in a structured form</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/0*ccc_RHaqD7ls7J8o" /></figure><h3>Here is the code to crawl and scrape the data from the website. Once extracted entire data from the web site, store it in the data frame.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*vuZXXQYEGecUNGhX" /></figure><h3>Here is the HTML code snippet which we need to identify the class for the respective parameters for extraction:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/0*-TKi1FT07YrI-z6g" /></figure><h3>I have extracted the product name, its price and rating for simplicity. Lets try to display the data we have extracted.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/0*5tZHsTBa2Se25fet" /></figure><h3>Now, we need to do the data cleaning for our analysis. Lets trim the currency “₹” and “,” and have only the price in the column. We use regex function by converting the datatype of the Price column to String as the datatype of all the columns is Object by default. Once it is trimmed, convert the datatype of Price and Rating to float type as below:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*DAXz8GC6jS5I18ww" /></figure><h3>Now lets see the data types after conversion:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/0*z4OrCf2JhQRdtgLb" /></figure><h3>Let’s see the data as well after trimming and conversion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*yMZa8Ro8ZfWK-yAh" /></figure><h3>Now, we need to filter the price range which was given as input</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/0*ss9UDqYHy7tw51TQ" /></figure><h3>Observed that the filtered data based on the price is displayed. It will difficult for us to understand what is the highest price with the rating for the product…. means we need to do a sorting in descending order on the price column and then by the Rating. This helps us to understand the highest rating of the mobile based on the price.</h3><h3>Here is the code to sort the data.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/0*K1CJqz5ZQFi39_iy" /></figure><h3>Let’s see the result after sorting. I am trying to display top 25 products.</h3><h3>Wow… it is sorted now as per our requirement.</h3><h3>Let us start visualizing the data in pictorial representation as picture speaks more than words.</h3><h3>Visualize the Mobile against the price.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/0*7s2ju7byZXGxZbEM" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/0*w-EuACqAQGkpMQIV" /></figure><h3>Similarly let’s try to plot the visualization for Products against the rating.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/0*uR6MLYy3yrNKhYAE" /></figure><h3>We can see that most of the mobile are rating more than 4 rating.</h3><h3>Now, let us plot the graph rating against the price using seaborn library:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*jxPn2HE6vjKw1e3Z" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/0*7ANZQTDFWu3YLi6C" /></figure><h3>With the above visualization we understand that all the mobiles are rated more than 4.4 within our budget.</h3><h3>Good… now let us see what are the top 3 mobiles with the high rating.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/0*T3Vss6UI9mHlNmRw" /></figure><h3>Conclusion:</h3><h3>Based on the above analysis, we understand that with in my budget (25K to 60K), I have got the top 3 mobiles with a very good rating.</h3><h3>This helps us to take quick decision to purchase mobile.</h3><h3>Same code can be used to scrape any product in the Flipkart website and come with the decisions quickly.</h3><h3>Hope it helps you to write the code and do the detailed visualization and analysis.</h3><h3>Will share few more blogs from my learning soon……. :)</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6259b31b51b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>