Created
September 28, 2019 16:28
-
-
Save pythonpaul/89a9890d099850783b82dc079b6e9884 to your computer and use it in GitHub Desktop.
Python requests + webbrowser app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import webbrowser | |
sites = ["https://en.wikipedia.org/wiki", | |
"http://www.bing.com/images/search"] | |
def openPage(x): | |
w = " " | |
if x == 0: | |
w = "wiki" | |
if x == 1: | |
w = "bing img" | |
q = raw_input(w + " search: ") | |
p = {"q": q} | |
r = requests.get(sites[x], params=p) | |
print("Status:", r.status_code) | |
webbrowser.open(r.url) | |
query = '' | |
while(query != 'iie'): | |
query = raw_input("U. w .U enter 'b' for bing image search, or 'w' for wikipedia search? ") | |
if query == "b": | |
openPage(1) | |
if query == "w": | |
openPage(0) | |
else: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment