What Will I Learn?
This tutorial covers the topics on obtaining information from the internet page by using Python.
- First of all you will learn how to Python setup for Windows briefly.
- Then, you will learn how to PyCharm which is a program to use Phyton language briefly.
- Then, you will learn how to add packages for Python by using PyCharm program.
- Then, you will learn how to import the packages briefly.
- Then, you will learn how to use for and if statements briefly.
- Then, you will learn how to obtain information from the internet page.
- Then, you will learn to get some information from Steemit member page.
Requirements
For this tutorial, you need Python 3.6.4 (actually you do not need newest version but always updating the Python is useful for you.) and PyCharm program.
- For Python 3.6.4 => you can download here for free.
- For PyCharm program => you can download here for free (30 days trial).
Difficulty
This tutorial has an indermadiate level.
Tutorial Contents
We want to build a program to make an analysis for Steemit members such as personalized tags, blog headings, wallet etc. Today, we will show how you can take information from a website by using Python.
First of we need to setup Python for Windows to use it. For this issue, below pictures are easy to understand and make setup:
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521577690/pmomiayqy0cv6t56qz4h.png]
Then we need to setup PyCharm program to work Python and you can download it like this:
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521577778/dstpqyetiwvjecy4zbzi.png]
After setup Python and PyCharm program, you need to open PyCharm program and the design will be like this and you can create files by right clicking the folder which is named untitled1 for us. Then you need to choose new and then Python file. After giving a name for file you are ready.
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521578113/na2nepfnddgucmufsa2i.png]
Now, you are ready to write your code in Python. Before starting to write the codes we need some packages which is written programmers and we can use these packages for free. We like Python due to its open source. Also you can create your packages and you can advertise it. Anyway, let's learn how to download packages. You need to choose File>Settings then there will be a pop-up menu which is related to general settings and also Project Interpreter menu. You can see the dowloaded packages and also you can add all packages here.
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521578503/j5w7dp39i4hwhwzsehqc.png]
For our tutorial we need to dowload beautifulsoup4 and requests packages.
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521578663/ce2htvfjpyowyymtgwdu.png]
We want to skip some basic learnings such as math operations, strings, variables, print etc. Also we think that with a written program you can learn a program much more easier. To achieve our goal for this tutorial, we will use two important operations which are for loop and if statement. We will explain these operations also into the code.
First of all, we need import the packages which we need to use in our program.
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521579074/j3xlgosdjvwocxkkk8ls.png]
Now, we need to find a website to get information from it. We used our Steemit homepage which is "https://steemit.com/@onderakcaalan" Lets see, what kind of info we can take from that page. To do that you can right click the page and choose Inspect, there wil be,
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521579490/odbe21pg058ljf3yencl.png]
in the Sources tag. These are the info which you can play:D. You can download it for yourself or make an analysis from the data or what ever you want. To get these info we will use requests command. Also we want to take html part of the wabpage which contains good sources by using BeautifulSoup package command. Here is the example:
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521581372/siiqdsq4o6k28r1snb2v.png]
If you want to see the results you can just write print command:
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1521581713/xgvyg3kr2mmqr0vzi0zk.png]
You can see, we have data which contains **"
Posted on Utopian.io - Rewarding Open Source Contributors