Giter Club home page Giter Club logo

imdb_webscraper's Introduction

Imdb WebScraper

Introduction

Web scraping is a method for obtaining large amount of datas from websites, such data are unstructured and difficult to work with hence we extract them change them to different file formats, modify them according to our needs. Here we have used data from the websites to populate our database. The programming language we are using is python because (it's easier ๐Ÿ˜) it can handle most processes easily. For library we use BeautifulSoup which is highly popular for web scraping. BeautifulSoup handles pulling out data from html or xml.

Installing libraries

We will install required library using pip (package installer for python).We are using beautifulSoup,requests for webscraping and mysql connector for inserting our datas in our database.

pip install bs4
pip install mysql-connector-python
pip install requests

You now can run the dbconnect.py and the code will execute

Playing with bs4

Our webscraper is the scrape.py script which will scrape the necessary datas from the official imdb site.

response = requests.get(url = movieUrl)
soup = BeautifulSoup(response.content,'html.parser')
  • We first specify the url from which we are going to scrape the data.
  • We then use beautiful soup to initialize a soup of the above url page using the html.parser as well.Now we can use this soup to extract any information we need from that page specified above.

Let's try to get the name of the movie.

image

Here as we can see the name enclosed within html tags and their attributes. We will now use the class attribute to find the data we are looking for using find(class_="class_name") also we can find tags as find('a')

Let's see it in code

movie_name = soup.find(class_="sc-94726ce4-2 khmuXj").find('h1')
movieName = movie_name.string
print(movieName) # prints out the movie name

Easy Right!!

Similarly you can play around extracting and scraping datas you need for your next project.

imdb_webscraper's People

Contributors

senor101 avatar

Watchers

 avatar

imdb_webscraper's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.