我正在尝试学习如何通过 python 脚本从互联网获取信息。这里是:
import requests
from bs4 import BeautifulSoup
url = 'https://www.amazon.es/Poco-NFC-Smartphone-Punch-Hole-Quad-c%C3%A1mara/dp/B08B9C149J/ref=sr_1_3?__mk_es_ES=%C3%85M%C3%85%C5%BD%C3%95%C3%91&dchild=1&keywords=poco%2Bx3&qid=1600179415&quartzVehicle=16-179&replacementKeywords=poco&sr=8-3&th=1'
headers ={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'}
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, "html.parser")
title = soup.find( id='productTitle').get_text()
问题是,当我应该获得在浏览器中看到的标题时,我却没有得到 ID“productTitle”搜索的结果。
有任何想法吗?
忽然笑
拉丁的传说
饮歌长啸
相关分类