Python:使用BeautifulSoup解析数据

时间:2016-09-14 09:45:26

标签: python urllib

我有一个网址列表

yandex.ru/search?text=игрушка%20"веселая%20гусеница"%20keenway%20отзывы&lr=47
yandex.ru/search?text=модис&lr=47
yandex.ru/search?text=модис&lr=47
yandex.ru/search?text=авито&lr=47
yandex.ru/search?text=авито&lr=47
yandex.ru/search?text=цветок%20киддиленд%20музыкальный&lr=47
dns-shop.ru/product/c7bf1138670f3361/rul-hori-racing-wheel
dns-shop.ru/product/c7bf1138670f3361/rul-hori-racing-wheel#opinion
kaluga.onlinetrade.ru/catalogue/ruli_dgoystiki_geympadi-c31/hori/reviews/rul_hori_racing_wheel_controller_ps_4_ps4_020e_acps440-274260.html
kazan.onlinetrade.ru/catalogue/ruli_dgoystiki_geympadi-c31/hori/reviews/rul_hori_racing_wheel_controller_xboxone_xbox_005u_acxone34-274261.html
kazan.onlinetrade.ru/catalogue/ruli_dgoystiki_geympadi-c31/hori/reviews/rul_hori_racing_wheel_controller_xboxone_xbox_005u_acxone34-274261.html
ebay.com

我需要从标记title获取文本到每个文本。

html = urllib.urlopen(url, proxies=proxies).read()
print html
soup = BeautifulSoup(html, 'html.parser')
titles = soup.title.get_text()

当我打印html时,我会得到真实的页面代码。但是当我尝试打印title时 我得到了

ERROR: The requested URL could not be retrieved

对于大多数网址。

那里有什么问题?

0 个答案:

没有答案