Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Ask HN: Building a side project that makes money. Where to start?.
import requests from bs4 import BeautifulSoup
url = "http://www.python.org" response = requests.get(url)
page = str(BeautifulSoup(response.content))
def getURL(page): """
:param page: html of web page (here: Python home page) :return: urls in that page """ start_link = page.find("a href") if start_link == -1: return None, 0 start_quote = page.find('"', start_link) end_quote = page.find('"', start_quote + 1) url = page[start_quote + 1: end_quote] return url, end_quote
There are no comments on this comment yet.
import requests from bs4 import BeautifulSoup
url = "http://www.python.org" response = requests.get(url)
page = str(BeautifulSoup(response.content))
def getURL(page): """
while True: url, n = getURL(page) page = page[n:] if url: print(url) else: break