Finding string in Array

:snoo: Solved

Practicing some simple web scraping + simultaneously learning how to manage arrays for our home buying excursion!

Problem:

For practice I'm looking to capture information from a random Zillow listing that is located under the "See more facts and features". This can be pulled in with the following formula:

=ArrayFormula(index(IMPORTXML("https://www.zillow.com/homedetails/6709-S-191st-Ave-Omaha-NE-68135/119782841_zpid/","//td[1]"),Match(1,countif(IMPORTXML("https://www.zillow.com/homedetails/6709-S-191st-Ave-Omaha-NE-68135/119782841_zpid/","//td[1]"),"MLS ID"),0)))

My issue is that when trying to filter to just "MLS ID" or "Bathrooms" the only value returned is 1, which is the value of Bedrooms and ergo yields "Bedrooms".

Is there a way to search the array in the cell that doesn't yield the position of one?

Edit - There isn't a way to pull this in via the API and would need me to either recode the address of each zillow url, or extract the ZPID of from each URL. Having been unable to extract the ZPID from the URL, I fell back to this method.

Posted Jun 20, 2019, 10:48 PM UTC

38
zero_sheets_given75•

You are using MATCH wrong. The first parameter is WHAT to search for, and the third parameter is the search mode.

What is your expected result here? there is probably a simpler solution.

1
DiamondMindOP•

Thank you! That did not solve it :(

My expected result is to return "MLS ID" and the number associated. I haven't built in the "| //td[2]" portion yet which would yield the actual ID if I understand XPath correctly Spoiler: I don't :(

1
zero_sheets_given75•

Instead of getting the td elements try getting the parent tr and it will return a table:

=QUERY(IMPORTXML("https://www.zillow.com/homedetails/6709-S-191st-Ave-Omaha-NE-68135/119782841_zpid/","//tr"),"select Col2 where Col1='MLS ID'")
2
DiamondMindOP•

TIL you can do SQL in google sheets.

Solution Verified.

2
zero_sheets_given75•

well, not really SQL but it supports some basic features, yes :)

see https://developers.google.com/chart/interactive/docs/querylanguage

2
Clippy_Office_AsstMOD:assistant: Points•

You have awarded 1 point to zero_sheets_given

^I ^am ^a ^bot, ^please ^contact ^the ^mods ^for ^any ^questions.

1
Decronym:assistant: Functions Explained•
1
Clippy_Office_AsstMOD:assistant: Points•

Read the comment thread for the solution here

Instead of getting the td elements try getting the parent tr and it will return a table:

=QUERY(IMPORTXML("https://www.zillow.com/homedetails/6709-S-191st-Ave-Omaha-NE-68135/119782841_zpid/","//tr"),"select Col2 where Col1='MLS ID'")

1