Skip to content

Instantly share code, notes, and snippets.

@pythonpaul
Created September 28, 2019 16:28

Revisions

  1. pythonpaul created this gist Sep 28, 2019.
    31 changes: 31 additions & 0 deletions wiki_bing_search.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    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