answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
makkiz [27]
1 year ago
7

You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web pa

ge, 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.
What you need to do?
1. Writing detailed comments and docstrings
2. Organizing and structuring code for readability
3. URL = :///
Steps for Completion
Task
Create two lists of strings - one list for Protocol called valid_protocols, and one list for storing File extension called valid_ftleinfo . For this take the protocol list should be restricted to http , https and ftp. The file extension list should be hrl. and docx CSV.
Split an input named url, and then use the first element to see whether the protocol of the URL is in valid_protocols. Similarly, check whether the URL contains a valid file_info.
Task
Write the conditions to return a Boolean value of True if the URL is valid, and False if either the Protocol or the File extension is not valid.
main.py х +
1 def validate_url(url):
2 *****Validates the given url passed as string.
3
4 Arguments:
5 url --- String, A valid url should be of form :///
6
7 Protocol = [http, https, ftp]
8 Hostname = string
9 Fileinfo = [.html, .csv, .docx]
10 ***
11 # your code starts here.
12
13
14
15 return # return True if url is valid else False
16
17
18 if
19 name _main__': url input("Enter an Url: ")
20 print(validate_url(url))
21
22
23
24
25
Computers and Technology
1 answer:
mixas84 [53]1 year ago
4 0

Answer:

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))

Explanation:

The image of the output code is attached. Hope it helps.

You might be interested in
HELP PLEASE ASAP brainliest to accurate
Svet_ta [14]
A patent law

Patent laws deal with new inventions and relays to the owner’s exclusive right to the claimed invention. It is a right that should be granted by the government to an inventor, to exclude others from using, making, importing, or selling an invention. In this case, Jenna's secret, unique recipe is her patent.


3 0
2 years ago
Read 2 more answers
A _______ bulb contains a high-pressure gas. Oils from the hands can affect the expansion of the glass, which can shorten the li
shusha [124]

Answer:

I'd go with the 2nd one

If it heats up more & more, then it's lifespan will be shortened more & more.  The more it heats up, the less durability it has.

6 0
1 year ago
What are two characteristics of a scalable network? (choose two.)?
vampirchik [111]

The two characteristics of scalable network are such that it can easily grow in size without causing any impact to the current users. This means, increase in network capacity and technical capability will not have any detrimental effects to the users.  Another characteristic of this network is that it can work perfectly with modular devices provided they   support expansion process.


7 0
2 years ago
A time-saving strategy that helps define unfamiliar words involves using
yuradex [85]

The correct answer is A. Familiar words for clues

Explanation:

Finding unfamiliar words is common while reading, especially in texts that belong to a specific field such as medicine, technology, etc. This can be handled through multiple strategies such as using a dictionary, guessing the meaning of the word based on its parts, and using context clues.

In this context, one of the easiest and most time-saving strategy is the use of context clues that implies using the familiar words as clues to guess the meaning of an unfamiliar word. This is effective because in most cases the meaning of an unknown word can be determined using the context of the word or words around the unknown word. Also, this strategy takes little time because you only need to analyze the sentence or paragraph where the unknown word is. Thus, the time-saving strategy to define unfamiliar words involves using familiar words for clues.

6 0
1 year ago
Read 2 more answers
The processing of data in a computer involves the interplay between its various hardware components.
Ronch [10]

True.

Data processing involves the conversion of raw data and the flow of data through the Central Processing Unit and Memory to output devices. Each CPU in a computer contains two primary elements: the Arithmetic Logic Unit (ALU) and the control unit. The Arithmetic Logic Unit performs complex mathematical calculations and logical comparisons. On the other hand, the control unit accesses computer instructions, decodes them, and controls the flow of data in and out of the Memory, ALU, primary and secondary storage, and various other output devices.  


8 0
2 years ago
Other questions:
  • Which are examples of copyrighted online materials? Check all that apply.
    14·2 answers
  • If a user was complaining about a "slow computer" due to a program that uses a significant amount of memory, what part or parts
    15·1 answer
  • Jane's organization recently experienced a security incident that occurred when malware set to trigger on the chief executive of
    13·1 answer
  • Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the givenprogram:Gus Bob Zoeshort_names
    13·1 answer
  • 10. (P37) Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently lon
    12·1 answer
  • As a digital forensics examiner, it’s a good idea to build a list of references for information on privacy laws in other countri
    13·1 answer
  • Jen is trying to discover if a motor has failed windings. What sort of test can she do.
    6·1 answer
  • A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative
    12·1 answer
  • Television broadcasts were originally delivered by using which technology
    14·1 answer
  • In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!