python USES the BeautifulSoup method of paginating hyperlinks in web pages

  • 2020-05-05 11:27:06
  • OfStack

This article illustrates how python USES BeautifulSoup to paginate hyperlinks in web pages. Share with you for your reference. The details are as follows:

python prints www.jb51.net all url links that contain jb51 on the net home page


from BeautifulSoup import BeautifulSoup
import urllib2
import re
url = urllib2.urlopen("//www.jb51.net")
content = url.read()
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True):
  if re.findall('sharejs', a['href']):
    print "Found the URL:", a['href']

I hope this article has been helpful to your Python programming.


Related articles: