0Pricing
Web Scraping & Bots · Ders

CSS Seçicileriyle DOM'da Gezinme

HTML ayrıştırırken öğeleri kesin biçimde hedeflemek için CSS seçicilerini BeautifulSoup ile kullanın ve temel etiket adı aramalarının ötesine geçin.

CSS Seçicileriyle DOM'da Gezinme, CoddyKit'te ücretsiz bir Web Scraping & Bots dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Web Scraping & Bots öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Web Scraping & Bots kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Why CSS Selectors?

You can find tags by name with BeautifulSoup, but real pages need precision. CSS selectors let you target elements exactly like a stylesheet would.

select vs find

BeautifulSoup offers select() (returns a list) and select_one() (returns the first match) that accept CSS selector strings.

from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
items = soup.select('li')
first = soup.select_one('h1')

Selecting by Class

Prefix a class name with a dot.

prices = soup.select('.price')
for p in prices:
    print(p.get_text())

Selecting by ID

Prefix an id with a hash. IDs are unique, so pair with select_one.

header = soup.select_one('#main-header')
print(header.get_text())

Descendant Selectors

A space means descendant: match elements nested anywhere inside another.

titles = soup.select('div.product h2')
for t in titles:
    print(t.get_text(strip=True))

Direct Child Selectors

A > matches only direct children, not deeper descendants.

rows = soup.select('table > tbody > tr')
print(len(rows))

Attribute Selectors

Target elements by attribute values inside square brackets.

links = soup.select('a[href^="https"]')
images = soup.select('img[alt]')

Combining Selectors

Chain conditions for tight targeting — tag, class and attribute together.

buttons = soup.select('button.cta[data-action="buy"]')

Extracting Attributes

Once selected, read attributes like href or src with bracket access.

for a in soup.select('a.product-link'):
    print(a['href'])

nth-of-type

Pseudo-classes like :nth-of-type pick elements by position.

second = soup.select('ul li:nth-of-type(2)')
print(second[0].get_text())

A Full Mini Example

Combine everything to scrape a list of product names and prices.

for card in soup.select('div.card'):
    name = card.select_one('.title').get_text(strip=True)
    price = card.select_one('.price').get_text(strip=True)
    print(name, price)

Quick Check

Which CSS selector matches an element whose class is exactly price?

Recap

You learned CSS selectors in BeautifulSoup:

  • select / select_one
  • Class (.), id (#), descendant and child (>) selectors
  • Attribute selectors and pseudo-classes
  • Extracting attributes

CSS selectors let you target exactly the data you need on complex pages.

Sıkça Sorulan Sorular

“CSS Seçicileriyle DOM'da Gezinme” dersi ücretsiz mi?

Evet — “CSS Seçicileriyle DOM'da Gezinme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Web Scraping & Bots kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Web Scraping & Bots kursu toplamda 4 dersten oluşur.

“CSS Seçicileriyle DOM'da Gezinme” dersinde ne öğreneceğim?

HTML ayrıştırırken öğeleri kesin biçimde hedeflemek için CSS seçicilerini BeautifulSoup ile kullanın ve temel etiket adı aramalarının ötesine geçin. Web Scraping & Bots ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Web Scraping & Bots öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Web Scraping & Bots, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“CSS Seçicileriyle DOM'da Gezinme” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Web Scraping & Bots dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Web Scraping & Bots dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Ortamınızı Kurma
  2. URL'ler İçin Requests Kullanımı
  3. BeautifulSoup ile Veri Çıkarma
  4. CSS Seçicileriyle DOM'da Gezinme
← Web Scraping & Bots Sayfasına Dön