私は、Python 3.5を使用して(同じウェブサイトから)URLのリストをこすりしようとしているのリストをスクレーピング:は、コードをURLの
import urllib.request
from bs4 import BeautifulSoup
url_list = ['URL1',
'URL2','URL3]
def soup():
for url in url_list:
sauce = urllib.request.urlopen(url)
for things in sauce:
soup_maker = BeautifulSoup(things, 'html.parser')
return soup_maker
# Scraping
def getPropNames():
for propName in soup.findAll('div', class_="property-cta"):
for h1 in propName.findAll('h1'):
print(h1.text)
def getPrice():
for price in soup.findAll('p', class_="room-price"):
print(price.text)
def getRoom():
for theRoom in soup.findAll('div', class_="featured-item-inner"):
for h5 in theRoom.findAll('h5'):
print(h5.text)
for soups in soup():
getPropNames()
getPrice()
getRoom()
をこれまでのところ、私はスープを印刷する場合、propNamesを取得し、 getPriceまたはgetRoomが動作するようです。しかし、私はそれが各URLを通過し、getPropNames、getPrice、getRoomを印刷するように見えることはできません。
Pythonを数ヶ月しか学習していないので、これでいくつかの助けに感謝します!
SebastianOpałczyńskiのおかげで、私はそれを取り上げ、その周りに頭を浮かべて、結果を知ってもらいましょう! – Maverick