从列表python中截取值

时间:2018-06-11 19:07:02

标签: python web-scraping

我有一个HTML文档,我使用

从中获取一些数据
data=content.find_all("a", {"class": "result-title"})

然后数据如下:

[ < a class = "result-title hover_feedback zred bold ln24 fontsize0 "
    data - result - type = "ResCard_Name"
    href = "https://www.zomato.com/bangalore/flechazo-marathahalli"
    title = "flechazo Restaurant, Marathahalli" > Flechazo <
    /a>]

现在我想要data的摘录 01. https://www.zomato.com/bangalore/flechazo-marathahalli 02. Flechazo

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

这将有助于

links = content.find_all("a", {"class": "result-title"})    
for link in links:
    print(link.get('href', None))
    print(link.text)

<强>输出

https://www.zomato.com/bangalore/flechazo-marathahalli
Flechazo