Extract class name in scrapy

前端 未结 3 2056
粉色の甜心
粉色の甜心 2021-01-19 11:41

I am trying to scrape rating off of trustpilot.com.

Is it possible to extract a class name using scrapy? I am trying to scrape a rating which is made up of five indi

3条回答
  •  死守一世寂寞
    2021-01-19 12:13

    You can extract rating directly using re_first() and re():

    for rating in response.xpath('//div[contains(@class, "star-rating")]/@class').re(r'count-(\d+)'):
        print(rating)
    

提交回复
热议问题