How can I use BeautifulSoup to search for all links on a page pointing to a specific domain?
Use SoupStrainer,
from BeautifulSoup import BeautifulSoup, SoupStrainer import re # Find all links links = SoupStrainer('a') [tag for tag in BeautifulSoup(doc, parseOnlyThese=links)] linkstodomain = SoupStrainer('a', href=re.compile('example.com/'))
Edit: Modified example from white paper.
Source: https://habr.com/ru/post/1299605/More articles:Work in several projects at the same time - organizationPHP script to find the age of a domain name - phpE-Commerce Website Interview Questions - e-commerceHow is zero? work in ruby? - ruby | fooobar.comCounting numbers in a float - c ++How can I accurately draw a rotated bitmap? - flashHow to configure winform to select date and time for default value? - c #Formatting Date in C # - c #Using iText, create in memory a PDF that is created on disk instead of - javaGL rendering stream on iphone, is it worth it? - multithreadingAll Articles