Answers for "extract url from a website using python"

1

how to read website from url using python

# Latest code adjusted according to the latest python version
import urllib.request
  	try:
		with urllib.request.urlopen('http://www.python.org/') as f:
			print(f.read().decode('utf-8'))
	except urllib.error.URLError as e:
		print(e.reason)
Posted by: Guest on January-08-2022
1

extract url from page python

from bs4 import BeautifulSoup

your_html = '<div class="itemContainer"> <a c="" href="/mp3s/mp3/Shadmehr-Aghili-Avaz-Nemishi"><div class="image_crop"><img alt="2f370b436731d9b" src="'


sp = BeautifulSoup(your_html)
sp.find('a').get('href')

# output:

# /mp3s/mp3/Shadmehr-Aghili-Avaz-Nemishi
Posted by: Guest on February-03-2021

Code answers related to "extract url from a website using python"

Python Answers by Framework

Browse Popular Code Answers by Language