Introduction
In this blog, I am going to get HTTP variables in Python. I will create one HTML file and will show the requested keyword opened in the web browser. The HTTP URL shows in the Python console screen.
Software requirement
Python 3.5 and IDE (Python 3.5)
Programming code
-
-
- import requests
-
- params={"q":"apple"}
-
- r=requests.get("http://www.google.com",params=params)
-
- print("status",r.status_code)
- print(r.url)
-
- f=open("./page.html","w+")
- f.write(r.text)
About the code
First, I am importing the "requests" modules.
Next, setting the parameter and requesting the website code.
Next, using the output statement to print the requested keyword URL in the console.
Finally, I have written the code to show the HTTP and keyword in a web browser.
Then, let’s execute the code.
Output