SORU
17 Ocak 2010, Pazar


Web Python ile kazıma

Bir web sitesinden günlük Gündoğumu/Günbatımı kez almak istiyorum. Kazımak web içeriği için mümkün Python ile? modüller kullanılır. Herhangi bir öğretici var mı?

CEVAP
17 Ocak 2010, Pazar


Sadece BeautifulSoup parlak kütüphane ile birlikte urllib2:

import urllib2
from BeautifulSoup import BeautifulSoup
# or if you're using BeautifulSoup4:
# from bs4 import BeautifulSoup

soup = BeautifulSoup(urllib2.urlopen('http://example.com').read())

for row in soup('table', {'class': 'spad'})[0].tbody('tr'):
    tds = row('td')
    print tds[0].string, tds[1].string
    # will print date and sunrise

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Google Analytics

    Google Analy

    25 ŞUBAT 2008
  • Joseph Herscher

    Joseph Hersc

    14 Mart 2007
  • Justin Davis

    Justin Davis

    14 Ocak 2008