Reading specific item from html file

Hi

Inside my text file, I am trying read the values “displayAddress”:“Wilmslow”.

So I want to get the name of every area after displayAddress and save it to a datatable but need guidance.

Find the attached text file below.
Properties.txt (823.1 KB)

Hi @tarmi.jacobs,

  1. Use the “Invoke Method” activity to call the “GetAttribute” method of the HTML element that contains the “displayAddress” value. This will retrieve the value of the “displayAddress” attribute. Assign the result to a variable named “address”.
  2. Use the “Assign” activity to assign the value of “address” to a variable named “addressString”. The expression would be: address.ToString()
  3. Use the “Split” function to split the string into an array of substrings, using the comma character (“,”) as the separator. Assign the result to a new variable named “addressArray”. The expression would be: addressString.Split(","c)
  4. Create a new datatable with four columns named “Area 1”, “Area 2”, “Area 3”, and “Area 4”.
  5. Use the “For Each” activity to iterate over the elements of the “addressArray” array.
  6. Inside the “For Each” activity, use the “If” activity to check if the current element starts with the string “displayAddress”. The condition would be: item.Trim().StartsWith("displayAddress")
  7. Inside the “If” activity, use the “Assign” activity to extract the name of the area and save it to the appropriate column in the datatable. The expression would be:
If (item.Trim().StartsWith("displayAddress"))
   dataTable.Rows.Add(item.Trim().Replace("displayAddress\":", "").Replace("""", ""))
End If

This code first checks if the current element starts with “displayAddress”. If it does, it removes the “displayAddress” text and any quotation marks from the element and adds the resulting string to the datatable.

  1. After the “For Each” activity, the datatable will contain the names of all areas after “displayAddress”.

Thank you for your reply!

Could you please elaborate on the Invoke Method because I’m not sure how that activity works.

Could you attach your working process?

@tarmi.jacobs
welcome to the forum

sample text looks like source code from a webpage
json we do see as an attribute from a script elment.

When you can open the page within the browser / scenario is about rerieve data from webpage:

  • we can combine some essential activites for the extraction

When text / text file is the source

  • one of more options is regex and JSON Parsing

Just let us know more about your case. Thanks

I am practicing automating a webpage so what I’m trying to do is loop through and click on every property in the URL, and extract the sell price, scroll down and extract the previous sale history.

Properties For Sale in M16 | Rightmove)