Created
May 13, 2021 02:49
-
-
Save it-jia/9f486e6038388c175ceab7f222ceffa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = 'https://www.wine.com/search/Capel%20Vale%20Winery%20Single%20Vineyard%20Kinnaird/0' | |
print(url) | |
r = requests.get(url) | |
if r.status_code == requests.codes.ok: | |
soup = BeautifulSoup(r.text, 'html.parser') | |
items = soup.select('ul.prodList li.prodItem') | |
for item in items: | |
name = item.select_one('.prodItemInfo_name').get('title') | |
price = item.select_one('meta[itemprop="price"]').get('content') | |
print('--------------------') | |
print('名稱:', name) | |
print('價格:', price) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
顯示資料如下: