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, 04.07.2019 19:20
Air enters a horizontal, constant-diameter heating duct operating at steady state at 290 k, 1 bar, with a volumetric flow rate of 0.25 m°/s, and exits at 325 k, 0.95 bar. the flow area is 0.04 m2. assuming the ideal gas model with k = 1.4 for the air, determine (a) the velocity at the inlet and exit, each in m/s, and (c) the rate of heat transfer, in kw flow rate, in kg/s, (b) the mass kg 0.3
Answers: 2
question
Engineering, 06.07.2019 02:30
Around steel bar, made from material with a yield stress of 750mpa, is loaded so that it has stresses co locations of maximum normal stress and maximum shear stress. use maximum shear stress and maximum distortion energy theories to calculate the safety factors for initial yielding failures.
Answers: 3
question
Engineering, 06.07.2019 03:10
Different between right hand turning tool and left hand turning tool ?
Answers: 1
question
Engineering, 06.07.2019 04:10
Water flows at the rate of 200 i/s upwards through a tapered vertical pipe. the diameter at marks(3) clo5) the bottom is 240 mm and at the top 200 mm and the length is 5m. the pressure at the bottom is 8 bar, and the pressure at the topside is 7.3 bar. determine the head loss through the pipe. express it as a function of exit velocity head.
Answers: 3
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
Biology, 11.05.2021 01:50
question
Computers and Technology, 11.05.2021 01:50
Questions on the website: 13722363