Question
Python WWW API Web and Search Understand the Application The National Academy of Science (NAS) marketing department is interested to get an accurate assessment on
Python WWW API
Web and Search
Understand the Application
The National Academy of Science (NAS) marketing department is interested to get an accurate assessment on the coverage of publicized topics on the current website. The marketing strategy team is divided over which of a list of topics is most widely represented on the website.
You have been hired to put a decision on the business operations (bizops) table as to which topic is most represented on the NAS website.
Specifically we will write a Python3 program that takes the URL of the National Academy of Science and a list of topics. For each topic of interest, your solution intelligence will compute the number of instances of each topic on the NAS website providing a simple yet complete report.
The Program Spec
Write a program that takes the NAS website url: http://www.nasonline.org (Links to an external site.)Links to an external site., downloads the HTML document, and decodes it into a string.
Create a list of the topics under review which include: research, climate, evolution, cultural and leadership. To provide additional insight to the bizops team, include an additional topic of your selection to the review list.
Determine the number of occurrences of each topic that appears on the webpage.
Provide a report summary that specifies the topic of interest and the number of times that the subject presents on the NAS website.
Import the datetime (Links to an external site.)Links to an external site.module to generate the date of your report run. Print this date in your run output.
Deliverable: yournameLab9.py Your source code solution and a copy of the run pasted into your source submission file. Be sure to comment out your run so that your .py file will still run in the grader test bed.
Test Run Requirements:
Here are some other tips and requirements:
1. Topic list contains the list of subjects in the program spec (including a minimum of one additional insight subject presented by you i.e. a minimum of 6 topics).
2. Generate a report summary that pairs the subject with the number of occurrences as measured by number of instances found of the topic on the website.
Here is a sample run:
Today's date is 2017-10-27 research appears 7 times.
...
***THIS python CODE NEEDS TO BE FIXED****
import time
print("Enter the URL, example(https://en.wikipedia.org/robots.txt)") url = input()
# Get the HTML Page response = requests.get(url) txt = response.text
# Strip the HTML Tags soup = BeautifulSoup(txt, "lxml") text = soup.get_text()
# Search for the keywords # I have used the extra topic under review as sports topics = ["sports", "research", "climate", "evolution", "cultural", "news"] out = []
for topic in topics: out.append(text.count(topic))
print("Todays date is " + time.strftime("%d/%m/%Y")) i = 0 for topic in topics: if out[i] > 0: print(topic + " appears " + str(out[i]) + " times.") i += 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started