Advertisement
kasougi

Untitled

Jul 2nd, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import requests
  3.  
  4. url = "https://ru.wikipedia.org/wiki/Python"
  5. html = requests.get(url)
  6. soup = BeautifulSoup(html.text, 'html.parser')
  7.  
  8. black_list = ['***', '***'] # вместо звездочек зарезанные ссылки
  9. res = {}
  10. for a in soup.findAll("a"):
  11.     if a.get("href") in black_list:
  12.         continue
  13.     if res.get(a.get("href")):
  14.         res[a.get("href")] += 1
  15.     else:
  16.         res[a.get("href")] = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement