subject
Engineering, 07.12.2021 14:00 Qpaoswp34

I You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web page, extracts the URLs present in that page, and then recursively fetches new pages using the extracted URLs. The end goal of a web crawler is to collect text data, images, or other resources present in order to validate resource URLs or hyperlinks on a page. URL validators can be useful to validate if the extracted URL is a valid resource to fetch. In this scenario, you will build a URL validator that checks for supported protocols and file types. That is my code: Python Code:

def validate_url(url):

#Creating the list of valid protocols and file name extensions

valid_protocols = ['http', 'https', 'ftp']

valid_fileinfo = ['.html', '.csv', '.docx']

#splitting the url into two parts

url_split = url. split('://')

isProtocolValid = False

isFileValid = False

#iterating over the valid protocols and file names for validity

for x in valid_protocols:

if x in url_split[0]:

isProtocolValid = True

break

for x in valid_fileinfo:

if x in url_split[1]:

isFileValid = True

break

#Returning the result if the URL has both valid protocol and file extension

return (isProtocolValid and isFileValid)

url = input("Enter an URL: ")

print(validate_url(url))
I need help fixing it because i am having a return error.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 19:30
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
question
Engineering, 04.07.2019 18:10
Which of the following refers to refers to how well the control system responds to sudden changes in the system. a)-transient regulation b)- distributed regulation c)-constant regulation d)-steady-state regulation
Answers: 1
question
Engineering, 04.07.2019 18:20
Asolid cylinder is concentric with a straight pipe. the cylinder is 0.5 m long and has an outside diameter of 8 cm. the pipe has an inside diameter of 8.5 cm. the annulus between the cylinder ad the pipe contains stationary oil. the oil has a specific gravity of 0.92 and a kinematic viscosity of 5.57 x 10-4 m2/s. most nearly, what is the force needed to move the cylinder along the pipe at a constant velocity of 1 m/s?
Answers: 3
question
Engineering, 04.07.2019 19:10
10 kg of co2 is initially contained at 400 kpa and 300 k. the gas constant for carbon dioxide is 189 j/lkg k) and has a specific heat ratio, k, of 1.289. isentropic expansion then occurs until the pressure is 200 kpa. a) determine the initial volume of co2 in m. b) determine the final temperature in k. c) determine the work done by the system during the expansion kl.
Answers: 2
You know the right answer?
I You have been tasked with building a URL file validator for a web crawler. A web crawler is an app...
Questions
question
Mathematics, 11.05.2021 20:40
question
Mathematics, 11.05.2021 20:40
Questions on the website: 13722360