001.py 711 B

1234567891011121314151617181920212223242526272829303132
  1. from bs4 import BeautifulSoup
  2. import requests
  3. x = 0
  4. while True:
  5. if x == 0:
  6. url = "https://news.ycombinator.com/newest"
  7. else:
  8. url = "https://news.ycombinator.com/newest" + nexx
  9. request = requests.get(url)
  10. soup = BeautifulSoup(request.text, "html.parser")
  11. teme = soup.find_all("td", class_="title")
  12. for temes in teme:
  13. temes = temes.find("a", {'class':'storylink'})
  14. if temes is not None and 'github.com' in str(temes):
  15. sublink = temes.get('href')
  16. print(str(temes.text) + " " + str(sublink))
  17. print("===")
  18. nex = soup.find(class_ = "morelink")
  19. nexlink = nex.get('href')
  20. nexx = nexlink[6:]
  21. x = x+1