📘 Lesson  ·  Lesson 98

Web Scraping (BeautifulSoup)

इस Project के बारे में

💡 एक नज़र में

BeautifulSoup web page का HTML पढ़ता है और titles, links, text जैसा data निकालने देता है।

Program

Python
import requests
from bs4 import BeautifulSoup

url = "https://example.com"
html = requests.get(url).text
soup = BeautifulSoup(html, "html.parser")

print("Title:", soup.title.text)

# page के सारे links
for link in soup.find_all("a"):
    print(link.get("href"))
Title: Example Domain https://www.iana.org/domains/example

ज़िम्मेदारी से Scrape करें

⚠️ Note

Scraping से पहले site का robots.txt और terms ज़रूर देखें। Servers पर ज़्यादा load न डालें।

सारांश

  • requests HTML लाता है; BeautifulSoup parse करता है।
  • Elements निकालने को soup.title, soup.find_all() use करें।
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.