/CS361_Microservice

A Wikipedia scraper microservice.

Primary LanguagePython


Wikipedia Scraper for Game Development Guide Microservice

Python Packages to Install

Open up Terminal.

pip install wikipedia

How to Start Microservice

Start the service in Terminal.

python wiki.py

How to REQUEST Data

Users can request data from this microservice by simply typing in a keyword into the interface’s search engine. It would then match up with the closest-matching Wikipedia article. Here is an example call:

# Clear
def clear():
    my_entry.delete(0, END)
    my_text.delete(0.0, END)


# Search
def search():
    data = wiki.page(my_entry.get())
    # Clear screen
    clear()
    # Output Wikipedia Results to Textbox
    my_text.insert(0.0, data.content)
    
    
>>> [wiki] Pulling information from {data.title}

How to RECEIVE Data

On the same file, there is a function that will gather all of the headings and details of the article from the Wikipedia URL that the user requested. All the user must do is type their keywords in the search engine and the appropriate data should appear on the screen. Said data will also go into a .txt file that the user gets to name of their choice. All .txt. files will go to the ./information directory.

# Write to File
def writeFile():
    save_path = './information'
    file_name = input("Article name: ") + ".txt"
    # Saving .txt file to the /information directory
    completeName = os.path.join(save_path, file_name)
    file = open(completeName, "a+")
    # Output Wikipedia Results to .txt file 
    file.write(my_text.get("1.0", 'end-1c') + '\n')
    file.close()


>>> Article name: {write your custom title here}

UML Sequence Diagram

UML Diagram

(back to top)