Question: this is a python program HTML is a language for representing documents designed to be displayed by a web browser. In many browsers, you can

this is a python program
HTML is a language for representing documents designed to be displayed by a web browser. In many browsers, you can see the HTML source code by right-clicking somewhere on the page and clicking View Page Source.
If you try this on a web page with links to other websites, youll notice that the URL of the link is usually formatted in the following way:
href="https://some.website.com/subfolder/more_stuff.txt"
Write a function extract_url(html) that takes in a string of html text that contains exactly one external link URL formatted as above, and returns just the URL string (in the above example, that would be https://some.website.com/subfolder/more_stuff.txt).
You can assume that the only place in the string where the substring href=" occurs is right before the URL, and that the next quotation mark after that point denotes the end of the URL.
Hints:
The .find method and string slicing will likely make this easier.
Remember that in order to use a double quote mark (") in a string, you either need to escape it with a backslash ("\""), or just use single quotes to begin/end the string ('"').
Examples:
>>> extract_url('title="Association for Computing Machinery">ACM DL: 81100248871')
'https://dl.acm.org/profile/81100248871'
>>> extract_url(']
  • Intact Forest Landscapes
  • ')
'http://www.intactforests.org/'
>>> extract_url('
< img src="https://www.cs.umn.edu/sites/cs.umn.edu/files/slider_images/evangrant2.png" width="800" height="500" alt="student submitted image, transcription available below" />
')
'https://www.cs.u

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!