代码之家  ›  专栏  ›  技术社区  ›  Prashant

从列表python中获取值

  •  0
  • Prashant  · 技术社区  · 6 年前

    我有一个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号。弗莱查佐

    任何帮助都将不胜感激。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Druta Ruslan    6 年前

    这会有帮助的

    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