Searching for text in Chrome

Hello all

I got the task of organizing the records for powerlifting club. This basically ends up being going to a webpage and clicking through drop down menus to pick age and weight classes. I then find my club’s name and copy the relevant information to a spreadsheet.
This was not too much work to do manually, but I’m afraid of making mistakes in the future.
I’m getting stuck on the part of searching for text in Google Chrome.
The code works so far, but I don’t seem to be able to search for text on the page.
I thought another idea would be to copy the text to a text file and search there, but the extra steps seemed unnecessary if there was a better way.


tell application "Google Chrome" to activate
tell application "System Events"
	tell process "Google Chrome"
		open location "http://webpage.com"
		delay 1 -- let the page load
	end tell
end tell

-- There's a lot of stuff here to select from drop down menus etc.

tell application "Google Chrome"
	select all of active tab of window 1
	copy selection of active tab of window 1
	
	if selection contains "Our Club Name" then
		-- get the person and their record which should be the text right before and after this
	end if
end tell

The copy selection part works if I want to paste it into a text document, but I’m trying to avoid extra steps.

Browser: Safari 537.22
Operating System: Mac OS X (10.8)

Hello.

If you open that page in Safari, then use the “page inspector” under the Developer menu (you’ll have to have it enabled). Once there, you’ll see how the hierarchy of the web page are built up by objects. I suggest you study the page there, but download the page as a text file with curl, and use handlers you can find here to extracts the bit of information you need.

1 Like

I would be afraid of the powerlifting club too…

You can either use curl (as McUsrII suggests) or “do Javascript” to get the value of page elements. Perhaps if you post the URL and the desired menu, someone may be able to help.