fairypp / Python_Learning

14 stars 8 forks source link

Using Python to Access Web Data_Coursera_Notes_Ch13_WebServices_BeautifulSoup #12

Open fairypp opened 8 years ago

fairypp commented 8 years ago
import urllib
from bs4 import BeautifulSoup
#from BeautifulSoup import *

url = raw_input('Enter - ')

html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)

# Retrieve a list of the anchor tags
# Each tag is like a dictionary of HTML attributes

tags = soup('a')

for tag in tags:
    print tag.get('href', None)
sheersh2001 commented 4 years ago

cc i am getting this trace back. can you help me out.