Python has a different module. Today we will learn the python request module. Request module is the request the website and sent the console data about request website. you will come the right place to learn the request module. Today we will learn the request module. First install the request module in your python terminal.
Use pip install request command to install the request module. Most the request module use the web developer to see the website status code. If the status code is 200 than that website is successfully host and website is live.
Python request module |
If the status code is 404 than that website is not live. Due to hosting error or domain error. Request module is use know the status code of any webpage of the website.
The advance programmer is use request module to web scraping. Web scraping is denger process. It is illegal things. Without permission wed scraping is the bad habit.Â
Uses of this module we can get the header text footer tex of the website. This request module is helpful for the web developer. Know the ststus code of our website we can rank our website in google. Now see the basic codeo f the to see the website status code.
How to see the status code of website
import requests
url_my = "https://codebugfree.com"
see_code = requests.get(url_my)
print(see_code)
Here we first import the request module. iside the my url variable input the website url. Request that url and need the status code
INOUTPUT
Response [200]
See what happen if we enter a wron url that url is not exist in that website
import requests
url_my = "https://codebugfree.com/home-page"
see_code = requests.get(url_my)
print(see_code)
INOUTPUT
Response [404]
How to get the Content of website using the Python request module
import requests
url_my = "https://codebugfree.com"
see_code = requests.get(url_my).content
print(see_code)
It program as a same to see the status code. Only see code variable their add content. If you there add text than you got a text of the website. If you write their headers than you got a header of a website.
0 Comments
Don't comment a spam message