Reptile first body

import requests # Invoke the requests library from bs4 import BeautifulSoup # Invoke the BeautifulSoup library res =requests.get(‘https://localprod.pandateacher.com/python-manuscript/crawler-html/spider-men5.0 .html’)# Return a response object and assign it to reshtml=res.text# Parse res as a string soup = BeautifulSoup( html,’html.parser’)# Parse the web page as a BeautifulSoup object items = soup.find_all(class_ =’books’) # Extract the elements we want by matching attribute class=’books’ for item in items: # Traverse the list items kind = item.find(‘h2’) # In each element in the list, Match tag

to extract data title = item.find(class_=’title’) # In each element in the list, match attribute class_=’title’ to extract data brief = item.find(class_=’info ‘) # In each element in the list, match the attribute class_=’info’ to extract the data print(kind.text,’
‘,title.text,’
‘,title[‘href’],’
‘,brief.text) # Print the type, name, link and introduction text of the book

Leave a Comment

Your email address will not be published.