Search code examples
google-sheetsgoogle-sheets-querygoogle-query-languagegoogle-sheets-formula

Import Craigslist information


I'm trying to import the data from Craigslist into Google Sheets. I'm using importxml and have made some progress but can further refine the function.

A3: https://norfolk.craigslist.org/ctd/d/2011-volkswagen-jetta-only-82k-miles/6910694177.html

=IMPORTXML(A3,"//div[@class='mapAndAttrs']//p[@class='attrgroup'][2]")

This seems to return all information but I want to trim it to search for fuel in the result and show gas/diesel/whatever may be.


Solution

  • =QUERY(TRANSPOSE(IMPORTXML(A3,
     "//div[@class='mapAndAttrs']//p[@class='attrgroup'][2]")), 
     "where Col1 contains 'fuel'")
    

    0


    =SUBSTITUTE(QUERY(TRANSPOSE(IMPORTXML(A3,
     "//div[@class='mapAndAttrs']//p[@class='attrgroup'][2]")), 
     "where Col1 contains 'fuel'"), "fuel: ", )
    

    0