Advertisement
skip420

getLinksFromWebpage

Aug 30th, 2022
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. from urllib.request import Request, urlopen
  3. import re
  4.  
  5. req = Request("https://pastebin.com/")
  6. html_page = urlopen(req)
  7.  
  8. soup = BeautifulSoup(html_page, "lxml")
  9.  
  10. links = []
  11. for link in soup.findAll('a'):
  12.     links.append(link.get('href'))
  13.  
  14. print(links)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement