Following Introduction to Computer Science track at Udacity, I\'m trying to make a python script to extract links from page, below is the code I used:
I got the fol
page
is undefined and that is the cause of error.
For web scraping like this, you can simply use beautifulSoup
:
from bs4 import BeautifulSoup, SoupStrainer
import requests
url = "http://stackoverflow.com/"
page = requests.get(url)
data = page.text
soup = BeautifulSoup(data)
for link in soup.find_all('a'):
print(link.get('href'))