Find and Findall Parameter:
findAll(tag, attributes, recursive, text, limit, keywords) find(tag, attributes, recursive, text, keywords)
Find Parameter:
beautifulsoup example Find h1 tag
import requests from bs4 import BeautifulSoup resp=requests.get("https://code-gym.github.io/spider_demo/") soup=BeautifulSoup(resp.text, 'html5lib') print(soup.find('h1'))
beautifulsoup print with tag and without
With tag
print(soup.find('h1'))
Without tag
print(soup.h1)
Findall parameter:
for h3 in soup.find_all('h3'): print(h3)
Find class name
for title in soup.find_all('h3','post-title'): print(title)
No comments:
Post a Comment