adyoiAvatar border
TS
adyoi
[Python] Grab Site dengan BeautifulSoup
Untuk pengguna windows download terlebih dahulu Python versi 2.7

https://www.activestate.com/activepython/downloads

cara install beautifulsoup4 perintah menggunakan :

Quote:



sudah terinstall emoticon-Big Grin

contoh penggunaan nya :

PHP Code:
#!/usr/bin/python

# tes.py

from BeautifulSoup import BeautifulSoup
html 
"<b>1</b><b>2</b><b>3</b>"
soup BeautifulSoup(html)
grab soup.findAll('b')
for 
item in grab:
 print 
item.text 


output nya



Cara Grab Site dengan Python BeautifulSoup :

PHP Code:
#!/usr/bin/python

# Kaskus HT by Adyoi 

from BeautifulSoup import BeautifulSoup as BS
import urllib2
opener 
urllib2.build_opener()
opener.addheaders = [('User-Agent''Mozilla/5.0')]
html opener.open('https://www.kaskus.co.id/')
soup BS(html)
elem soup.findAll('a')
for 
item in elem:
 if 
item.get('name') == 'ht_title':
  for 
itemz in item.findAll('h3'):
   print 
itemz.text 


HT kaskus hari ini (7/6/17-2:26)
Diubah oleh adyoi 06-07-2017 07:53
nona212Avatar border
nona212 memberi reputasi
1
1.4K
1
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Urutan
Terbaru
Terlama
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan